Setup_Video::Setup_Video(): mFullScreenEnabled(config.getBoolValue("screen")), mOpenGLEnabled(config.getBoolValue("opengl")), mCustomCursorEnabled(config.getBoolValue("customcursor")), mParticleEffectsEnabled(config.getBoolValue("particleeffects")), mFps(config.getIntValue("fpslimit")), mSDLTransparencyDisabled(config.getBoolValue("disableTransparency")), mModeListModel(new ModeListModel), mModeList(new ListBox(mModeListModel)), mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)), mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)), mParticleEffectsCheckBox(new CheckBox(_("Particle effects"), mParticleEffectsEnabled)), mFpsCheckBox(new CheckBox(_("FPS limit:"))), mFpsSlider(new Slider(10, 120)), mFpsLabel(new Label), mOverlayDetail(config.getIntValue("OverlayDetail")), mOverlayDetailSlider(new Slider(0, 2)), mOverlayDetailField(new Label), mParticleDetail(3 - config.getIntValue("particleEmitterSkip")), mParticleDetailSlider(new Slider(0, 3)), mParticleDetailField(new Label), mDisableSDLTransparencyCheckBox( new CheckBox(_("Disable transparency (Low CPU mode)"), mSDLTransparencyDisabled)) { setName(_("Video")); Spacer *space = new Spacer(0,10); ScrollArea *scrollArea = new ScrollArea(mModeList); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setSize(100, 200); overlayDetailLabel = new Label(_("Ambient FX:")); particleDetailLabel = new Label(_("Particle detail:")); mModeList->setEnabled(true); #ifndef USE_OPENGL mOpenGLCheckBox->setEnabled(false); #endif mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None")); mFpsLabel->setWidth(60); mFpsSlider->setValue(mFps); mFpsSlider->setEnabled(mFps > 0); mFpsCheckBox->setSelected(mFps > 0); overlayDetailLabel->setAlignment(Graphics::RIGHT); particleDetailLabel->setAlignment(Graphics::RIGHT); // If the openGL Mode is enabled, disabling the transaprency // is irrelevant. mDisableSDLTransparencyCheckBox->setEnabled(!mOpenGLEnabled); // Pre-select the current video mode. std::string videoMode = toString(graphics->getWidth()) + "x" + toString(graphics->getHeight()); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); // Set actions mModeList->setActionEventId("videomode"); mCustomCursorCheckBox->setActionEventId("customcursor"); mParticleEffectsCheckBox->setActionEventId("particleeffects"); mDisableSDLTransparencyCheckBox->setActionEventId("disableTransparency"); mFpsCheckBox->setActionEventId("fpslimitcheckbox"); mFpsSlider->setActionEventId("fpslimitslider"); mOverlayDetailSlider->setActionEventId("overlaydetailslider"); mOverlayDetailField->setActionEventId("overlaydetailfield"); mOpenGLCheckBox->setActionEventId("opengl"); mParticleDetailSlider->setActionEventId("particledetailslider"); mParticleDetailField->setActionEventId("particledetailfield"); // Set listeners mModeList->addActionListener(this); mCustomCursorCheckBox->addActionListener(this); mOpenGLCheckBox->addActionListener(this); mParticleEffectsCheckBox->addActionListener(this); mDisableSDLTransparencyCheckBox->addActionListener(this); mFpsCheckBox->addActionListener(this); mFpsSlider->addActionListener(this); mOverlayDetailSlider->addActionListener(this); mOverlayDetailField->addKeyListener(this); mParticleDetailSlider->addActionListener(this); mParticleDetailField->addKeyListener(this); mOverlayDetailField->setCaption(overlayDetailToString(mOverlayDetail)); mOverlayDetailSlider->setValue(mOverlayDetail); mParticleDetailField->setCaption(particleDetailToString(mParticleDetail)); mParticleDetailSlider->setValue(mParticleDetail); // Do the layout ContainerPlacer place = getPlacer(0, 0); place.getCell().setHAlign(LayoutCell::FILL); place(0, 0, scrollArea, 1, 4).setPadding(2).setHAlign(LayoutCell::FILL); place(1, 0, space, 1, 4); place(2, 0, mFsCheckBox); place(2, 1, mOpenGLCheckBox); place(2, 2, mCustomCursorCheckBox); place = getPlacer(0, 1); place.getCell().setHAlign(LayoutCell::FILL); place(0, 0, space, 3); place(0, 1, mDisableSDLTransparencyCheckBox, 4); place(0, 2, mFpsCheckBox); place(1, 2, mFpsSlider, 2); place(3, 2, mFpsLabel); place(0, 3, mParticleEffectsCheckBox, 4); place(0, 4, particleDetailLabel); place(1, 4, mParticleDetailSlider, 2); place(3, 4, mParticleDetailField); place(0, 5, overlayDetailLabel); place(1, 5, mOverlayDetailSlider, 2); place(3, 5, mOverlayDetailField); }
/** Puts all widgets into the menu. */ MenuGameLobby::MenuGameLobby(){ setDimension(Rectangle(0, 0, MENUWIDTH, MENUHEIGHT)); CustomContainer* contControl = new CustomContainer(); contControl->setDimension (Rectangle(getWidth()/32, getHeight()/32, getWidth(), getHeight() / 16)); add(contControl); buttonBack = new Button("Leave"); buttonBack->setPosition(0, 0); buttonBack->addActionListener(new BackActionListener); contControl->add(buttonBack); buttonStartGame = new Button("Start"); buttonStartGame->setPosition(buttonBack->getWidth() * 3 / 2, 0); buttonStartGame->addActionListener(new StartGameActionListener); contControl->add(buttonStartGame); PlayersSelectionListener* playersselectionlistener = new PlayersSelectionListener; listLocalPlayers = new ListBox(new LocalPlayersListModel); listLocalPlayers->addSelectionListener(playersselectionlistener); ScrollArea* scrollLocalPlayers = new ScrollArea(listLocalPlayers, gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); scrollLocalPlayers->setSize(getWidth() / 4, getHeight() / 2); scrollLocalPlayers->setPosition(getWidth() / 20, getHeight() / 8); add(scrollLocalPlayers); listLocalPlayers->setWidth(scrollLocalPlayers->getWidth()); CustomContainer::setColor(listLocalPlayers); listPlayers = new ListBox(new PlayersListModel); listPlayers->addSelectionListener(playersselectionlistener); ScrollArea* scrollPlayers = new ScrollArea(listPlayers, gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); scrollPlayers->setSize(getWidth() / 5 * 2, getHeight() / 2); scrollPlayers->setPosition(getWidth() / 20 * 11, getHeight() / 8); add(scrollPlayers); listPlayers->setWidth(scrollPlayers->getWidth()); CustomContainer::setColor(listPlayers); buttonAddPlayer = new Button("Add >"); buttonAddPlayer->addActionListener(new AddPlayerActionListener); buttonAddPlayer->setVisible(false); add(buttonAddPlayer); int playerbuttonwidth = buttonAddPlayer->getWidth(); int playerbuttonheight = buttonAddPlayer->getHeight(); buttonRemovePlayer = new Button("< Remove"); buttonRemovePlayer->addActionListener(new RemovePlayerActionListener); buttonRemovePlayer->setVisible(false); add(buttonRemovePlayer); playerbuttonwidth = (buttonRemovePlayer->getWidth() > playerbuttonwidth) ? buttonRemovePlayer->getWidth() : playerbuttonwidth; playerbuttonwidth = playerbuttonwidth * 3 / 2; buttonAddPlayer->setWidth(playerbuttonwidth); buttonRemovePlayer->setWidth(playerbuttonwidth); buttonAddPlayer->setPosition( (scrollLocalPlayers->getX()+scrollLocalPlayers->getWidth()+scrollPlayers->getX()-buttonAddPlayer->getWidth()) / 2, getHeight() / 8); buttonRemovePlayer->setPosition( (scrollLocalPlayers->getX()+scrollLocalPlayers->getWidth()+scrollPlayers->getX()-buttonRemovePlayer->getWidth()) / 2, getHeight() / 4); dropTeams = new DropDown(new TeamsListModel); dropTeams->addSelectionListener(new TeamsSelectionListener); dropTeams->setWidth(playerbuttonwidth); dropTeams->setPosition( (scrollLocalPlayers->getX()+scrollLocalPlayers->getWidth()+scrollPlayers->getX()-dropTeams->getWidth()) / 2, getHeight() / 8 * 3); dropTeams->setVisible(true); add(dropTeams); dropTeam = new DropDown(new TeamListModel); dropTeam->addSelectionListener(new TeamSelectionListener); dropTeam->setWidth(playerbuttonwidth); dropTeam->setPosition( (scrollLocalPlayers->getX()+scrollLocalPlayers->getWidth()+scrollPlayers->getX()-dropTeam->getWidth()) / 2, getHeight() / 16 * 7); add(dropTeam); Label* labelPoints = new Label("Points to win:"); labelPoints->setPosition( (scrollLocalPlayers->getX()+scrollLocalPlayers->getWidth()+scrollPlayers->getX()-dropTeam->getWidth()) / 2 - 16, getHeight() / 2); add(labelPoints); sliderLimit = new Slider(1, 100); sliderLimit->addActionListener(new LimitSliderActionListener()); sliderLimit->setSize(playerbuttonwidth, playerbuttonheight / 2); sliderLimit->setPosition( (scrollLocalPlayers->getX()+scrollLocalPlayers->getWidth()+scrollPlayers->getX()-sliderLimit->getWidth()) / 2, scrollLocalPlayers->getY()+scrollLocalPlayers->getHeight()-sliderLimit->getHeight()); sliderLimit->setVisible(true); sliderLimit->setValue(10); add(sliderLimit); buttonLimitLeft = new Button("-"); buttonLimitRight = new Button("+"); buttonLimitLeft->addActionListener(new LimitLeftActionListener()); buttonLimitRight->addActionListener(new LimitRightActionListener()); buttonLimitLeft->setPosition(sliderLimit->getX(), sliderLimit->getY()-buttonLimitLeft->getHeight()-2); buttonLimitRight->setPosition( sliderLimit->getX()+sliderLimit->getWidth()-buttonLimitRight->getWidth(), sliderLimit->getY()-buttonLimitRight->getHeight()-2); buttonLimitLeft->setVisible(true); buttonLimitRight->setVisible(true); add(buttonLimitLeft); add(buttonLimitRight); fieldLimit = new TextField(intToString(gameplay.limit)); fieldLimit->setPosition( buttonLimitLeft->getX()+buttonLimitLeft->getWidth(), buttonLimitLeft->getY()); fieldLimit->setSize( buttonLimitRight->getX()-buttonLimitLeft->getX()-buttonLimitLeft->getWidth(), playerbuttonheight); fieldLimit->setEnabled(false); fieldLimit->setFocusable(false); fieldLimit->setVisible(true); add(fieldLimit); CustomContainer* contChat = new CustomContainer(); contChat->setDimension (Rectangle(getWidth() / 36, getHeight() / 3 * 2, getWidth() / 3 * 2, getHeight() / 10 * 3)); buttonChat = new Button("Send"); buttonChat->addActionListener(new ChatActionListener); fieldChat = new ChatTextField(); textChat = new TextBox(""); CustomContainer* contChatBox = new CustomContainer(); contChatBox->setDimension (Rectangle(0, 0, contChat->getWidth(), contChat->getHeight() - buttonChat->getHeight())); scrollChat = new ScrollArea(textChat, gcn::ScrollArea::SHOW_AUTO, gcn::ScrollArea::SHOW_ALWAYS); scrollChat->setPosition(0, 0); scrollChat->setSize(contChatBox->getWidth(), contChatBox->getHeight()); textChat->setPosition(0, 0); CustomContainer::setColor(textChat); textChat->setSize (scrollChat->getWidth()-scrollChat->getScrollbarWidth(), scrollChat->getHeight()); textChat->setEditable(false); CustomContainer::setColor(textChat); fieldChat->setWidth(contChat->getWidth()-buttonChat->getWidth()); buttonChat->setPosition(fieldChat->getWidth(),textChat->getHeight()); fieldChat->setPosition(0,buttonChat->getY()+(buttonChat->getHeight()-fieldChat->getHeight()) / 2); add(contChat); contChat->add(contChatBox); contChatBox->add(scrollChat); contChat->add(fieldChat); contChat->add(buttonChat); iconMap = new Icon(); iconMap->setDimension(Rectangle(getWidth() * 3 / 4, getHeight() * 5 / 7, 96, 96)); iconMap->setVisible(true); add(iconMap); }