📄 gameoptionsdialog.java
字号:
|| !editable) { optionComp.setEditable(false); } } else if (option.getName().equals("protos_move_multi")) { //$NON-NLS-1$ if ( (options.getOption("protos_move_even")).booleanValue() //$NON-NLS-1$ || (options.getOption("protos_move_later")).booleanValue() //$NON-NLS-1$ || !editable) { optionComp.setEditable(false); } } else if (option.getName().equals("protos_move_even")) { //$NON-NLS-1$ if ( (options.getOption("protos_move_multi")).booleanValue() //$NON-NLS-1$ || (options.getOption("protos_move_later")).booleanValue() //$NON-NLS-1$ || !editable) { optionComp.setEditable(false); } } else if (option.getName().equals("protos_move_later")) { //$NON-NLS-1$ if ( (options.getOption("protos_move_even")).booleanValue() //$NON-NLS-1$ || (options.getOption("protos_move_multi")).booleanValue() //$NON-NLS-1$ || !editable ) { optionComp.setEditable(false); } } else if (option.getName().equals("visibility")) { //$NON-NLS-1$ if ( !(options.getOption("double_blind")).booleanValue() //$NON-NLS-1$ || !editable ) { optionComp.setEditable(false); } } else { optionComp.setEditable( editable ); } optionComps.addElement(optionComp); } // Gets called when one of the options gets moused over. public void showDescFor(IOption option) { texDesc.setText(option.getDescription()); } // Gets called when one of the option checkboxes is clicked. // Arguments are the GameOption object and the true/false // state of the checkbox. public void optionClicked(DialogOptionComponent comp, IOption option, boolean state) { if (option.getName().equals("inf_move_even")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("inf_deploy_even")) { //$NON-NLS-1$ comp_i.setEditable(state); comp_i.setState(false); } if (comp_i.option.getName().equals("inf_move_multi")) { //$NON-NLS-1$ comp_i.setEditable(!state); } if (comp_i.option.getName().equals("inf_move_later")) { //$NON-NLS-1$ comp_i.setEditable(!state); } } } if (option.getName().equals("inf_move_multi")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("inf_move_even")) { //$NON-NLS-1$ comp_i.setEditable(!state); } if (comp_i.option.getName().equals("inf_move_later")) { //$NON-NLS-1$ comp_i.setEditable(!state); } } } if (option.getName().equals("inf_move_later")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("inf_move_even")) { //$NON-NLS-1$ comp_i.setEditable(!state); } if (comp_i.option.getName().equals("inf_move_multi")) { //$NON-NLS-1$ comp_i.setEditable(!state); } } } if (option.getName().equals("protos_move_even")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("protos_deploy_even")) { //$NON-NLS-1$ comp_i.setEditable(state); comp_i.setState(false); } if (comp_i.option.getName().equals("protos_move_multi")) { //$NON-NLS-1$ comp_i.setEditable(!state); } if (comp_i.option.getName().equals("protos_move_later")) { //$NON-NLS-1$ comp_i.setEditable(!state); } } } if (option.getName().equals("protos_move_multi")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("protos_move_even")) { //$NON-NLS-1$ comp_i.setEditable(!state); } if (comp_i.option.getName().equals("protos_move_later")) { //$NON-NLS-1$ comp_i.setEditable(!state); } } } if (option.getName().equals("protos_move_later")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("protos_move_even")) { //$NON-NLS-1$ comp_i.setEditable(!state); } if (comp_i.option.getName().equals("protos_move_multi")) { //$NON-NLS-1$ comp_i.setEditable(!state); } } } if (option.getName().equals("individual_initiative")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("protos_deploy_even")) { //$NON-NLS-1$ comp_i.setEditable(false); comp_i.setState(false); } if (comp_i.option.getName().equals("protos_move_even")) { //$NON-NLS-1$ comp_i.setEditable(!state); comp_i.setState(false); } if (comp_i.option.getName().equals("protos_move_multi")) { //$NON-NLS-1$ comp_i.setEditable(!state); comp_i.setState(false); } if (comp_i.option.getName().equals("protos_move_later")) { //$NON-NLS-1$ comp_i.setEditable(!state); comp_i.setState(false); } if (comp_i.option.getName().equals("inf_deploy_even")) { //$NON-NLS-1$ comp_i.setEditable(false); comp_i.setState(false); } if (comp_i.option.getName().equals("inf_move_even")) { //$NON-NLS-1$ comp_i.setEditable(!state); comp_i.setState(false); } if (comp_i.option.getName().equals("inf_move_multi")) { //$NON-NLS-1$ comp_i.setEditable(!state); comp_i.setState(false); } if (comp_i.option.getName().equals("inf_move_later")) { //$NON-NLS-1$ comp_i.setEditable(!state); comp_i.setState(false); } } } if (option.getName().equals("vacuum")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("fire")) { //$NON-NLS-1$ comp_i.setEditable(!state); comp_i.setState(false); } } } if (option.getName().equals("double_blind")) { //$NON-NLS-1$ for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp_i = (DialogOptionComponent)i.nextElement(); if (comp_i.option.getName().equals("visibility")) { //$NON-NLS-1$ comp_i.setEditable(state); } } } } private void setupButtons() { butOkay.addActionListener(this); butCancel.addActionListener(this); butDefaults.addActionListener(this); // layout GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); panButtons.setLayout(gridbag); c.insets = new Insets(5, 5, 5, 5); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.VERTICAL; c.ipadx = 20; c.ipady = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; gridbag.setConstraints(butOkay, c); panButtons.add(butOkay); c.anchor = GridBagConstraints.WEST; gridbag.setConstraints(butCancel, c); panButtons.add(butCancel); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(butDefaults, c); panButtons.add(butDefaults); } private void setupPassword() { panPassword.setLayout(new BorderLayout()); panPassword.add(labPass, BorderLayout.WEST); panPassword.add(texPass, BorderLayout.CENTER); } public void actionPerformed(ActionEvent e) { if (e.getSource() == butOkay) { if(client != null) { send(); } doSave(); } else if (e.getSource() == butDefaults) { resetToDefaults(); return; } else if (e.getSource() == butCancel ){ refreshOptions(); } this.setVisible(false); } /** * Update the dialog so that it is editable or view-only. * * @param editable - <code>true</code> if the contents of the dialog * are editable, <code>false</code> if they are view-only. */ public void setEditable( boolean editable ) { // Set enabled state of all of the option components in the dialog. for ( Enumeration i = optionComps.elements(); i.hasMoreElements(); ) { DialogOptionComponent comp = (DialogOptionComponent) i.nextElement(); comp.setEditable( editable ); } // If the panel is editable, the player can commit or reset. texPass.setEnabled( editable ); butOkay.setEnabled( editable ); butDefaults.setEnabled( editable ); // Update our data element. this.editable = editable; } /** * Determine whether the dialog is editable or view-only. * * @return <code>true</code> if the contents of the dialog are * editable, <code>false</code> if they are view-only. */ public boolean isEditable() { return this.editable; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -