How Random Babbling Becomes Corporate Policy (t3knomanser) wrote,
How Random Babbling Becomes Corporate Policy
t3knomanser

  • Music:

I'm going to stop programming now...

...but, I was documenting my code...


/**
   * 

JBuilder generated function. Initializes screen display elements.

* @throws java.lang.Exception There's no exception handling here. */ void jbInit() throws Exception { jLabelName.setText("Attribute: "); this.setLayout(xYLayout1); jLabelD.setText("d"); //Use the CyclingSpinnerListModel I found online. Should cite that. //Don't remember URL. //TODO: Fucking look it up cheezbal. SpinnerListModel s = new CyclingSpinnerListModel(Global.attrDieTypes); jSpinnerDieType = new JSpinner(s); jSpinnerDieType.addChangeListener(new Attrib_jSpinnerDieType_changeAdapter(this)); jSpinnerNumDice.addChangeListener(new Attrib_jSpinnerNumDice_changeAdapter(this)); this.setMaximumSize(new Dimension(140, 34)); jSpinnerNumDice.setBorder(BorderFactory.createLineBorder(Color.black)); jSpinnerNumDice.setMaximumSize(new Dimension(29, 22)); jSpinnerNumDice.setPreferredSize(new Dimension(29, 24)); jSpinnerDieType.setBorder(BorderFactory.createLineBorder(Color.black)); jSpinnerDieType.setMaximumSize(new Dimension(29, 22)); jSpinnerDieType.setPreferredSize(new Dimension(29, 24)); this.add(jLabelName, new XYConstraints(19, 11, -1, -1)); this.add(jSpinnerNumDice, new XYConstraints(79, 3, 50, 25)); this.add(jSpinnerDieType, new XYConstraints(149, 3, 50, 25)); this.add(jLabelD, new XYConstraints(136, 9, -1, -1)); } /** *

Using an attribute, set the values here. This function was supposed to * be more important than it ended up being. Goes to show.

* @param d The attribute being used. */ public void set(Attribute d) { jLabelName.setText(d.getName() + ":"); jSpinnerNumDice.setValue(new Integer(d.getNum())); jSpinnerDieType.setValue(new Integer(d.getType())); } /** *

Oh, here it gets interesting. Event handler for the DieType spinner. * Cycles between 0, 4, 6, and 8, the valid types for a COTS character. Will * add some method for allowing it to accept other ranges for races, but there's * no race logic as yet, so lump it.

* @param e */ void jSpinnerDieType_stateChanged(ChangeEvent e) { Integer i = (Integer)jSpinnerDieType.getValue(); int dieType = i.intValue(); /*if (dieType == 0) { jSpinnerDieType.setValue(jSpinnerDieType.getNextValue()); }*/ while (data.availableDieTypes(dieType) == 0) { jSpinnerDieType.setValue(jSpinnerDieType.getNextValue()); i = (Integer)jSpinnerDieType.getValue(); dieType = i.intValue(); /*if (dieType == 0) { jSpinnerDieType.setValue(jSpinnerDieType.getNextValue()); }*/ } try { data.assignDie(pos, dieType); } catch (InvalidDieType ex) { } } /** *

Don't let me document my code when I'm bitter at JBuilder. Why I'm using * this fucktarded program I'll never know... oh wait... because Eclipse's VE * doesn't work at all. This is an event handler for the NumDice spinner, * ranged 1-5.

* @param e */ void jSpinnerNumDice_stateChanged(ChangeEvent e) { if (initalized) { Integer i = (Integer) jSpinnerNumDice.getValue(); int newDie = i.intValue(); if (newDie > lastDieNum) { if (data.availableFreeAttributeDice() > 0) { data.spendFreeDie(pos); } else { data.spendFreebies(data.buyExtraDie(pos)); } } else { if (data.availableFreeAttributeDice() < Global.FREEDICE) { data.unspendFreeDie(pos); } else { data.spendFreebies(data.dropExtraDie(pos) * -1); } } lastDieNum = newDie; forceUpdate(); } } /** *

This fires the AttributeChange event to all of the listeners. Right now * this consists of frmMain. All that work for one listener. And, as I think * about it, using "Update" as the method name is fucktarded. But it was easy * to remember. My code, right? Fuck off

*/ protected void forceUpdate() { Object[] listenerList = listeners.toArray(); for (int i = 0; i < listenerList.length; i++) { AttributeChangeListener temp = (AttributeChangeListener)listenerList[i]; temp.update(); } }


No more coding for me.
Subscribe

  • Strange Things People Say About Me (to my face)

    Recently, I've been at the center of a trend. That trend is complete strangers asking me "Are you ____?" A quick summary. For example: Are you…

  • Writer's Block: If I could find my way

    -10,000 years, at minimum. Tomorrow is always better than today, especially when you can't fact-check.

  • Bob Morlang

    When I was working at Tri-Mount, we had these camp trucks. They were army surplus, and while they could take a beating, they only sort of worked. And…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 2 comments