void ScrollBar::OnDraw() { Object::OnDraw(); if (this->skinName == "") { Container* parent = dynamic_cast<Container*>(this->parent); if (parent != NULL) { ScrollArea* area = parent->_getScrollArea(); if (area != NULL) { if (area->isDragging() || area->isScrolling()) { this->_retainTime = RETAIN_TIME; } if ((!this->useFading || this->_retainTime > 0.0f) && (!this->heightHide || this->_checkAreaSize())) { april::Color color = this->_getDrawColor(); if (this->useFading && this->_retainTime < FADE_OUT_TIME) { color.a = (unsigned char)hclamp(color.a * this->_retainTime / FADE_OUT_TIME, 0.0f, 255.0f); } april::rendersys->drawFilledRect(this->_getBarDrawRect(), color); } } } } }
Setup_Keyboard::Setup_Keyboard(): mKeyListModel(new KeyListModel), mKeyList(new ListBox(mKeyListModel)), mKeySetting(false) { keyboard.setSetupKeyboard(this); setName(_("Keyboard")); refreshKeys(); mKeyList->addActionListener(this); ScrollArea *scrollArea = new ScrollArea(mKeyList); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mAssignKeyButton = new Button(_("Assign"), "assign", this); mAssignKeyButton->addActionListener(this); mAssignKeyButton->setEnabled(false); mMakeDefaultButton = new Button(_("Default"), "makeDefault", this); mMakeDefaultButton->addActionListener(this); // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, scrollArea, 4, 6).setPadding(2); place(0, 6, mMakeDefaultButton); place(3, 6, mAssignKeyButton); setDimension(gcn::Rectangle(0, 0, 365, 280)); }
WorldSelectDialog::WorldSelectDialog(Worlds worlds): Window(_("Select World")) { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); ScrollArea *worldsScroll = new ScrollArea(mWorldList); mChangeLoginButton = new Button(_("Change Login"), "login", this); mChooseWorld = new Button(_("Choose World"), "world", this); worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); place(0, 0, worldsScroll, 3, 5).setPadding(2); place(1, 5, mChangeLoginButton); place(2, 5, mChooseWorld); // Make sure the list has enough height getLayout().setRowHeight(0, 60); reflowLayout(0, 0); if (worlds.size() == 0) // Disable Ok button mChooseWorld->setEnabled(false); else // Select first server mWorldList->setSelected(0); addKeyListener(this); center(); setVisible(true); mChooseWorld->requestFocus(); }
HelpPage() { Box *vbox = new VBox(); ScrollArea* scroll = new ScrollArea(); scroll->fitToParent(true); RichText *text = new RichText(HELP_TEXT); scroll->virtualSize(Vec2(SCREEN_WIDTH,text->layout(SCREEN_WIDTH))); text->fitToParent(true); text->alpha(100); scroll->add(text,0,0); vbox->add( scroll, 0, 1 ); vbox->add( new Button("http://numptyphysics.garage.maemo.org",Event::SELECT), 36, 0 ); m_content->add(vbox,0,0); }
HelpPage() { Box *vbox = new VBox(); ScrollArea* scroll = new ScrollArea(); scroll->fitToParent(true); RichText *text = new RichText(help_text_html, help_text_html_len); scroll->virtualSize(Vec2(SCREEN_WIDTH,text->layout(SCREEN_WIDTH))); text->fitToParent(true); text->alpha(100); scroll->add(text,0,0); vbox->add( scroll, 0, 1 ); vbox->add( new Button(PROJECT_HOMEPAGE,Event::SELECT), 36, 0 ); m_content->add(vbox,0,0); }
void GuildWindow::newGuildTab(const std::string &guildName) { // Create new tab GuildListBox *list = new GuildListBox; list->setListModel(player_node->getGuild(guildName)); ScrollArea *sa = new ScrollArea(list); sa->setDimension(gcn::Rectangle(5, 5, 135, 250)); // Add the listbox to the map mGuildLists.insert(std::pair<std::string, GuildListBox*>(guildName, list)); mGuildTabs->addTab(guildName, sa); mGuildTabs->setDimension(gcn::Rectangle(28,35,140,250)); updateTab(); }
NpcPostDialog::NpcPostDialog(int npcId): Window(_("NPC")), mNpcId(npcId) { setContentSize(400, 180); // create text field for receiver gcn::Label *senderText = new Label(_("To:")); senderText->setPosition(5, 5); mSender = new TextField; mSender->setPosition(senderText->getWidth() + 5, 5); mSender->setWidth(65); // create button for sending Button *sendButton = new Button(_("Send"), "send", this); sendButton->setPosition(400 - sendButton->getWidth(), 170 - sendButton->getHeight()); Button *cancelButton = new Button(_("Cancel"), "cancel", this); cancelButton->setPosition(sendButton->getX() - (cancelButton->getWidth() + 2), sendButton->getY()); // create textfield for letter mText = new TextBox; mText->setHeight(400 - (mSender->getHeight() + sendButton->getHeight())); mText->setEditable(true); // create scroll box for letter text ScrollArea *scrollArea = new ScrollArea(mText); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle( 5, mSender->getHeight() + 5, 380, 140 - (mSender->getHeight() + sendButton->getHeight()))); add(senderText); add(mSender); add(scrollArea); add(sendButton); add(cancelButton); center(); instances.push_back(this); setVisible(true); PlayerInfo::setNPCPostCount(PlayerInfo::getNPCPostCount() + 1); }
LevelSelector(GameControl* game, int initialLevel) : m_game(game), m_levels(game->m_levels), m_collection(0), m_dispbase(0), m_dispcount(0) { m_scroll = new ScrollArea(); m_scroll->fitToParent(true); m_scroll->virtualSize(Vec2(SCREEN_WIDTH,SCREEN_HEIGHT)); m_content->add(m_scroll,0,0); fitToParent(true); int levelInC; m_collection = m_levels->collectionFromLevel(initialLevel,&levelInC); setCollection(m_collection, levelInC); }
bool ScrollBar::onMouseScroll(float x, float y) { if (Object::onMouseScroll(x, y)) { return true; } Container* parent = dynamic_cast<Container*>(this->parent); if (parent != NULL && (parent->isCursorInside() || this->isCursorInside())) { ScrollArea* area = parent->_getScrollArea(); if (area != NULL && area->isSwapScrollWheels()) { hswap(x, y); } this->addScrollValue(this->_calcScrollMove(x, y)); } return false; }
ServerSelectDialog::ServerSelectDialog(LoginData *loginData, State nextState): Window(_("Select Server")), mLoginData(loginData), mNextState(nextState) { mServerListModel = new ServerListModel; mServerList = new ListBox(mServerListModel); ScrollArea *mScrollArea = new ScrollArea(mServerList); mOkButton = new Button(_("OK"), "ok", this); Button *mCancelButton = new Button(_("Cancel"), "cancel", this); setContentSize(200, 100); mCancelButton->setPosition( 200 - mCancelButton->getWidth() - 5, 100 - mCancelButton->getHeight() - 5); mOkButton->setPosition( mCancelButton->getX() - mOkButton->getWidth() - 5, 100 - mOkButton->getHeight() - 5); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setDimension(gcn::Rectangle( 5, 5, 200 - 2 * 5, 100 - 3 * 5 - mCancelButton->getHeight() - mScrollArea->getFrameSize())); mServerList->setActionEventId("ok"); //mServerList->addActionListener(this); add(mScrollArea); add(mOkButton); add(mCancelButton); if (n_server == 0) // Disable Ok button mOkButton->setEnabled(false); else // Select first server mServerList->setSelected(0); center(); setVisible(true); mOkButton->requestFocus(); }
void TextBox::scrollToCaret() { Widget *par = getParent(); if (par == NULL) { return; } ScrollArea* scrollArea = dynamic_cast<ScrollArea *>(par); if (scrollArea != NULL) { Rectangle scroll; scroll.x = getFont()->getWidth(mTextRows[mCaretRow].substr(0, mCaretColumn)); scroll.y = getFont()->getHeight() * mCaretRow; scroll.width = 6; scroll.height = getFont()->getHeight() + 2; // add 2 for some extra space scrollArea->scrollToRectangle(scroll); } }
void ScrollBar::_initAreaDragging() { Container* parent = dynamic_cast<Container*>(this->parent); if (parent != NULL) { ScrollArea* area = parent->_getScrollArea(); if (area != NULL) { if (area->_dragSpeed.x == 0.0f) { area->_lastScrollOffset.x = area->getScrollOffsetX(); area->_dragTimer.x = 0.0f; } if (area->_dragSpeed.y == 0.0f) { area->_lastScrollOffset.y = area->getScrollOffsetY(); area->_dragTimer.y = 0.0f; } } } }
void ListBox::setSelected(int selected) { if (mListModel == NULL) { mSelected = -1; } else { if (selected < 0) { mSelected = -1; } else if (selected >= mListModel->getNumberOfElements()) { mSelected = mListModel->getNumberOfElements() - 1; } else { mSelected = selected; } Widget *par = getParent(); if (par == NULL) { return; } ScrollArea* scrollArea = dynamic_cast<ScrollArea *>(par); if (scrollArea != NULL) { Rectangle scroll; scroll.y = getFont()->getHeight() * mSelected; scroll.height = getFont()->getHeight(); scrollArea->scrollToRectangle(scroll); } } setDirty(true); }
//initialize according to the type and the cube database // void TabWidget::initialize( cube::Cube* cube, QString fileName, cubeparser::Driver* driver, Statistics* statistics ) { this->cube = cube; TreeWidget* treeWidget; if ( type == METRICTAB ) { //metric tabs have a metric tree ScrollArea* scrollArea = new ScrollArea( this, ScrollAreaTreeWidget ); treeWidget = new TreeWidget( scrollArea, METRICTREE, fileName, driver, statistics ); connect( treeWidget, SIGNAL( setMessage( QString ) ), this, SIGNAL( setMessage( QString ) ) ); treeWidget->setFont( treeFont ); treeWidget->setSpacing( spacing ); treeWidget->setTabWidget( this ); treeWidget->initialize( cube ); scrollArea->setMainWidget( treeWidget ); addTab( scrollArea, "Metric tree" ); } else if ( type == CALLTAB ) { //call tabs have a call tree and a flat call profile ScrollArea* scrollArea = new ScrollArea( this, ScrollAreaTreeWidget ); treeWidget = new TreeWidget( scrollArea, CALLTREE, fileName, driver, statistics ); connect( treeWidget, SIGNAL( setMessage( QString ) ), this, SIGNAL( setMessage( QString ) ) ); treeWidget->setFont( treeFont ); treeWidget->setSpacing( spacing ); treeWidget->setTabWidget( this ); treeWidget->initialize( cube ); scrollArea->setMainWidget( treeWidget ); addTab( scrollArea, "Call tree" ); scrollArea = new ScrollArea( this, ScrollAreaTreeWidget ); treeWidget = new TreeWidget( scrollArea, CALLFLAT ); connect( treeWidget, SIGNAL( setMessage( QString ) ), this, SIGNAL( setMessage( QString ) ) ); treeWidget->setFont( treeFont ); treeWidget->setSpacing( spacing ); treeWidget->setTabWidget( this ); treeWidget->initialize( cube ); scrollArea->setMainWidget( treeWidget ); addTab( scrollArea, "Flat view" ); } else if ( type == SYSTEMTAB ) { subsetCombo = new QComboBox(); subsetCombo->setModel( &subsetModel ); subsetCombo->setWhatsThis( tr( "The Boxplot uses the currently selected subset of threads when determining its statistics." " Other defined subsets can be chosen from the combobox menu, such as \"All\" threads or" " \"Visited\" threads for only threads that visited the currently selected callpath." " Additional subsets can be defined from the System Tree with the \"Define subset\" context menu" " using the currently selected threads via multiple selection (control + left mouseclick)" " or with the \"Find items\" context menu selection option." ) ); fillSubsetCombo(); connect( subsetCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( displayItems() ) ); connect( subsetCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateSubsetCombo() ) ); //system tabs have a system tree, topologies and box plot { ScrollArea* scrollArea = new ScrollArea( this, ScrollAreaTreeWidget ); treeWidget = new TreeWidget( scrollArea, SYSTEMTREE ); connect( treeWidget, SIGNAL( setMessage( QString ) ), this, SIGNAL( setMessage( QString ) ) ); connect( treeWidget, SIGNAL( selectionChanged() ), this, SLOT( resetSubsetCombo() ) ); treeWidget->setFont( treeFont ); treeWidget->setSpacing( spacing ); treeWidget->setTabWidget( this ); treeWidget->initialize( cube ); scrollArea->setMainWidget( treeWidget ); SplitterContainer* container = new SplitterContainer(); container->setComponent( treeWidget ); // main component, used in TabWidget container->addWidget( scrollArea ); connect( treeWidget, SIGNAL( definedSubsetsChanged( const QString & ) ), this, SLOT( fillSubsetCombo( const QString & ) ) ); container->addWidget( subsetCombo ); QList<int> sizeList; sizeList << container->size().height() << 1; container->setSizes( sizeList ); addTab( container, "System tree" ); } { // box plot tab SplitterContainer* container = new SplitterContainer(); ScrollArea* scrollArea = new ScrollArea( this, ScrollAreaBoxPlot ); systemBoxWidget = new SystemBoxPlot( scrollArea, treeWidget ); scrollArea->setMainWidget( systemBoxWidget ); scrollArea->setWidgetResizable( true ); scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); container->setComponent( systemBoxWidget ); // main component, used in TabWidget container->addWidget( scrollArea ); // set lower splitter element to minimum size (1 pixel => replaced by minimumSize()) QList<int> sizeList; sizeList << container->size().height() << 1; container->setSizes( sizeList ); systemBoxPlotIndex = addTab( container, "Box Plot" ); } { SystemTopologyWidget* systemTopologyWidget; unsigned numTopologies = cube->get_cartv().size(); for ( unsigned i = 0; i < numTopologies; i++ ) { QString name = ( cube->get_cartv() ).at( i )->get_name().c_str(); if ( name == "" ) { name.append( "Topology " ); name.append( QString::number( i ) ); } SplitterContainer* container = new SplitterContainer(); systemTopologyWidget = new SystemTopologyWidget( treeWidget, i ); systemTopologyWidget->setLineType( lineType ); systemTopologyWidget->initialize( cube ); container->setComponent( systemTopologyWidget ); container->addWidget( systemTopologyWidget ); /** add topology dimension toolbar with scrollPane */ QWidget* dimBar = systemTopologyWidget->getDimensionSelectionBar( cube ); if ( dimBar != 0 ) { QScrollArea* scroll = new QScrollArea(); container->addWidget( scroll ); scroll->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); scroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); scroll->setFrameStyle( QFrame::NoFrame ); scroll->setMinimumHeight( dimBar->minimumSizeHint().height() ); scroll->setMaximumHeight( dimBar->minimumSizeHint().height() ); scroll->setWidget( dimBar ); long ndims = ( cube->get_cartv() ).at( i )->get_ndims(); if ( ndims <= 3 ) // minimize dimension selection bar { QList<int> sizeList; sizeList << 1 << 0; container->setSizes( sizeList ); } } addTab( container, name ); } } // SYSTEMTAB }
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); }
void setCollection(int c, int levelInC) { if (c < 0 || static_cast<unsigned int>(c) >=m_levels->numCollections()) { return; } m_collection = c; m_dispbase = 0; m_dispcount = m_levels->collectionSize(c); m_scroll->virtualSize(Vec2(SCREEN_WIDTH,150+(SCREEN_HEIGHT/ICON_SCALE_FACTOR+40)*((m_dispcount+2)/3))); m_scroll->empty(); Box *vbox = new VBox(); vbox->add( new Spacer(), 10, 0 ); Box *hbox = new HBox(); Widget *w = new Button("<<",Event::PREVIOUS); w->border(false); hbox->add( w, BUTTON_WIDTH, 0 ); hbox->add( new Spacer(), 10, 0 ); Label *title = new Label(m_levels->collectionName(c)); title->font(Font::headingFont()); title->alpha(100); hbox->add( title, BUTTON_WIDTH, 4 ); w= new Button(">>",Event::NEXT); w->border(false); hbox->add( new Spacer(), 10, 0 ); hbox->add( w, BUTTON_WIDTH, 0 ); vbox->add( hbox, 64, 0 ); vbox->add( new Spacer(), 10, 0 ); hbox = new HBox(); hbox->add( new Spacer(), 0, 1 ); int accumw = 0; for (int i=0; i<m_dispcount; i++) { accumw += SCREEN_WIDTH / ICON_SCALE_FACTOR + 10; if (accumw >= SCREEN_WIDTH) { vbox->add(hbox, SCREEN_HEIGHT/ICON_SCALE_FACTOR+30, 4); vbox->add( new Spacer(), 10, 0 ); hbox = new HBox(); hbox->add( new Spacer(), 0, 1 ); accumw = SCREEN_WIDTH / ICON_SCALE_FACTOR; } m_thumbs[i] = new IconButton("--","",Event(Event::PLAY, //SELECT, m_levels->collectionLevel(c,i))); m_thumbs[i]->font(Font::blurbFont()); m_thumbs[i]->setBg(SELECTED_BG); m_thumbs[i]->border(false); hbox->add( m_thumbs[i], SCREEN_WIDTH / ICON_SCALE_FACTOR, 0 ); hbox->add( new Spacer(), 0, 1 ); } vbox->add(hbox, SCREEN_HEIGHT/ICON_SCALE_FACTOR+30, 4); vbox->add( new Spacer(), 110, 10 ); m_scroll->add(vbox,0,0); for (int i=0; i<THUMB_COUNT && i+m_dispbase<m_dispcount; i++) { Canvas temp( SCREEN_WIDTH, SCREEN_HEIGHT ); Scene scene( true ); unsigned char buf[64*1024]; int level = m_levels->collectionLevel(c,i); int size = m_levels->load( level, buf, sizeof(buf) ); if ( size && scene.load( buf, size ) ) { scene.draw( temp, FULLSCREEN_RECT ); m_thumbs[i]->text( m_levels->levelName(level) ); m_thumbs[i]->canvas( temp.scale( ICON_SCALE_FACTOR ) ); m_thumbs[i]->transparent(m_dispbase+i!=levelInC); } } }
TradeWindow::TradeWindow(): Window(_("Trade: You")), mMyInventory(new Inventory(INVENTORY_SIZE)), mPartnerInventory(new Inventory(INVENTORY_SIZE)), mStatus(PROPOSING) { setWindowName("Trade"); setResizable(true); setCloseButton(true); setDefaultSize(386, 180, ImageRect::CENTER); setMinWidth(386); setMinHeight(180); std::string longestName = getFont()->getWidth(_("OK")) > getFont()->getWidth(_("Trade")) ? _("OK") : _("Trade"); mAddButton = new Button(_("Add"), "add", this); mOkButton = new Button("", "", this); // Will be filled in later int width = std::max(mOkButton->getFont()->getWidth(CAPTION_PROPOSE), mOkButton->getFont()->getWidth(CAPTION_CONFIRMED)); width = std::max(width, mOkButton->getFont()->getWidth(CAPTION_ACCEPT)); width = std::max(width, mOkButton->getFont()->getWidth(CAPTION_ACCEPTED)); mOkButton->setWidth(8 + width); mMyItemContainer = new ItemContainer(mMyInventory.get()); mMyItemContainer->addSelectionListener(this); ScrollArea *myScroll = new ScrollArea(mMyItemContainer); myScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mPartnerItemContainer = new ItemContainer(mPartnerInventory.get()); mPartnerItemContainer->addSelectionListener(this); ScrollArea *partnerScroll = new ScrollArea(mPartnerItemContainer); partnerScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mMoneyLabel = new Label(strprintf(_("You get %s."), "")); gcn::Label *mMoneyLabel2 = new Label(_("You give:")); mMoneyField = new TextField; mMoneyField->setWidth(40); mMoneyChangeButton = new Button(_("Change"), "money", this); place(1, 0, mMoneyLabel); place(0, 1, myScroll).setPadding(3); place(1, 1, partnerScroll).setPadding(3); ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, mMoneyLabel2); place(1, 0, mMoneyField); place(2, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT); place = getPlacer(0, 2); place(0, 0, mAddButton); place(1, 0, mOkButton); Layout &layout = getLayout(); layout.extend(0, 2, 2, 1); layout.setRowHeight(1, Layout::AUTO_SET); layout.setRowHeight(2, 0); layout.setColWidth(0, Layout::AUTO_SET); layout.setColWidth(1, Layout::AUTO_SET); loadWindowState(); reset(); }
void SkillDialog::loadSkills() { clearSkills(); XML::Document doc(SKILLS_FILE); xmlNodePtr root = doc.rootNode(); int setCount = 0; std::string setName; ScrollArea *scroll; SkillListBox *listbox; SkillTab *tab; if (!root || !xmlStrEqual(root->name, BAD_CAST "skills")) { logger->log("Error loading skills file: %s", SKILLS_FILE); if (Net::getNetworkType() == ServerInfo::TMWATHENA) { SkillModel *model = new SkillModel(); SkillInfo *skill = new SkillInfo; skill->id = 1; skill->name = "basic"; skill->setIcon(""); skill->modifiable = true; skill->visible = true; skill->model = model; skill->update(); model->addSkill(skill); mSkills[1] = skill; model->updateVisibilities(); listbox = new SkillListBox(model); scroll = new ScrollArea(listbox); scroll->setOpaque(false); scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); tab = new SkillTab("Skills", listbox); mTabs->addTab(tab, scroll); update(); } return; } for_each_xml_child_node(set, root) { if (xmlStrEqual(set->name, BAD_CAST "set")) { setCount++; setName = XML::getProperty(set, "name", strprintf(_("Skill Set %d"), setCount)); SkillModel *model = new SkillModel(); for_each_xml_child_node(node, set) { if (xmlStrEqual(node->name, BAD_CAST "skill")) { int id = atoi(XML::getProperty(node, "id", "-1").c_str()); std::string name = XML::getProperty(node, "name", strprintf(_("Skill %d"), id)); std::string icon = XML::getProperty(node, "icon", ""); SkillInfo *skill = new SkillInfo; skill->id = id; skill->name = name; skill->setIcon(icon); skill->modifiable = false; skill->visible = false; skill->model = model; skill->update(); model->addSkill(skill); mSkills[id] = skill; } } model->updateVisibilities(); listbox = new SkillListBox(model); scroll = new ScrollArea(listbox); scroll->setOpaque(false); scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); tab = new SkillTab(setName, listbox); mTabs->addTab(tab, scroll); } }
ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): Window(_("Choose Your Server")), mDir(dir), mDownloadStatus(DOWNLOADING_PREPARING), mDownloadProgress(-1.0f), mServers(ServerInfos()), mServerInfo(serverInfo) { setWindowName("ServerDialog"); Label *serverLabel = new Label(_("Server:")); Label *portLabel = new Label(_("Port:")); Label *typeLabel = new Label(_("Server type:")); mServerNameField = new TextField(mServerInfo->hostname); mPortField = new TextField(toString(mServerInfo->port)); loadCustomServers(); mServersListModel = new ServersListModel(&mServers, this); mServersList = new ServersListBox(mServersListModel); ScrollArea *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mTypeListModel = new TypeListModel(); mTypeField = new DropDown(mTypeListModel); mTypeField->setSelected((serverInfo->type == ServerInfo::MANASERV) ? 1 : 0); mDescription = new Label(std::string()); mQuitButton = new Button(_("Quit"), "quit", this); mConnectButton = new Button(_("Connect"), "connect", this); mManualEntryButton = new Button(_("Custom Server"), "addEntry", this); mDeleteButton = new Button(_("Delete"), "remove", this); mServerNameField->setActionEventId("connect"); mPortField->setActionEventId("connect"); mServerNameField->addActionListener(this); mPortField->addActionListener(this); mManualEntryButton->addActionListener(this); mServersList->addSelectionListener(this); usedScroll->setVerticalScrollAmount(0); place(0, 0, serverLabel); place(1, 0, mServerNameField, 4).setPadding(3); place(0, 1, portLabel); place(1, 1, mPortField, 4).setPadding(3); place(0, 2, typeLabel); place(1, 2, mTypeField, 4).setPadding(3); place(0, 3, usedScroll, 5, 5).setPadding(3); place(0, 8, mDescription, 5); place(0, 9, mManualEntryButton); place(1, 9, mDeleteButton); place(3, 9, mQuitButton); place(4, 9, mConnectButton); // Make sure the list has enough height getLayout().setRowHeight(3, 80); // Do this manually instead of calling reflowLayout so we can enforce a // minimum width. int width = 0, height = 0; getLayout().reflow(width, height); if (width < 400) { width = 400; getLayout().reflow(width, height); } setContentSize(width, height); setMinWidth(getWidth()); setMinHeight(getHeight()); setDefaultSize(getWidth(), getHeight(), ImageRect::CENTER); setResizable(true); addKeyListener(this); loadWindowState(); setFieldsReadOnly(true); mServersList->setSelected(0); // Do this after for the Delete button setVisible(true); if (mServerNameField->getText().empty()) { mServerNameField->requestFocus(); } else { if (mPortField->getText().empty()) mPortField->requestFocus(); else mConnectButton->requestFocus(); } downloadServerList(); }
Setup_Video::Setup_Video(): mFullScreenEnabled(config.getBoolValue("screen")), mOpenGLEnabled(config.getIntValue("opengl")), mCustomCursorEnabled(config.getBoolValue("customcursor")), mFps(config.getIntValue("fpslimit")), mAltFps(config.getIntValue("altfpslimit")), mEnableResize(config.getBoolValue("enableresize")), mNoFrame(config.getBoolValue("noframe")), mModeListModel(new ModeListModel), mModeList(new ListBox(mModeListModel)), mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)), mEnableResizeCheckBox(new CheckBox(_("Enable resize"), mEnableResize)), mNoFrameCheckBox(new CheckBox(_("No frame"), mNoFrame)), mFpsCheckBox(new CheckBox(_("FPS limit:"))), mFpsSlider(new Slider(2, 160)), mFpsLabel(new Label), mAltFpsSlider(new Slider(2, 160)), mAltFpsLabel(new Label(_("Alt FPS limit: "))), #ifdef WIN32 mDetectButton(new Button(_("Detect best mode"), "detect", this)), #else mDetectButton(nullptr), #endif mDialog(nullptr) { setName(_("Video")); ScrollArea *scrollArea = new ScrollArea(mModeList); scrollArea->setWidth(150); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mOpenGLListModel = new OpenGLListModel; mOpenGLDropDown = new DropDown(mOpenGLListModel), mOpenGLDropDown->setSelected(mOpenGLEnabled); mModeList->setEnabled(true); #ifndef USE_OPENGL mOpenGLDropDown->setSelected(0); #endif mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None")); mFpsLabel->setWidth(60); mAltFpsLabel->setCaption(_("Alt FPS limit: ") + (mAltFps > 0 ? toString(mAltFps) : _("None"))); mAltFpsLabel->setWidth(150); mFpsSlider->setValue(mFps); mFpsSlider->setEnabled(mFps > 0); mAltFpsSlider->setValue(mAltFps); mAltFpsSlider->setEnabled(mAltFps > 0); mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. std::string videoMode = toString(mainGraphics->mWidth) + "x" + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); mModeList->setActionEventId("videomode"); mCustomCursorCheckBox->setActionEventId("customcursor"); mFpsCheckBox->setActionEventId("fpslimitcheckbox"); mFpsSlider->setActionEventId("fpslimitslider"); mAltFpsSlider->setActionEventId("altfpslimitslider"); mOpenGLDropDown->setActionEventId("opengl"); mEnableResizeCheckBox->setActionEventId("enableresize"); mNoFrameCheckBox->setActionEventId("noframe"); mModeList->addActionListener(this); mCustomCursorCheckBox->addActionListener(this); mFpsCheckBox->addActionListener(this); mFpsSlider->addActionListener(this); mAltFpsSlider->addActionListener(this); mOpenGLDropDown->addActionListener(this); mEnableResizeCheckBox->addActionListener(this); mNoFrameCheckBox->addActionListener(this); // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, scrollArea, 1, 5).setPadding(2); place(0, 5, mOpenGLDropDown, 1); place(1, 0, mFsCheckBox, 2); place(1, 1, mCustomCursorCheckBox, 3); place(1, 2, mEnableResizeCheckBox, 2); place(1, 3, mNoFrameCheckBox, 2); place(0, 6, mFpsSlider); place(1, 6, mFpsCheckBox).setPadding(3); place(2, 6, mFpsLabel).setPadding(1); place(0, 7, mAltFpsSlider); place(1, 7, mAltFpsLabel).setPadding(3); #ifdef WIN32 place(0, 8, mDetectButton); #endif int width = 600; if (config.getIntValue("screenwidth") >= 730) width += 100; setDimension(gcn::Rectangle(0, 0, width, 300)); }
ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): Window(_("Choose Your Server")), mDir(dir), mDownloadStatus(DOWNLOADING_PREPARING), mDownloadProgress(-1.0f), mServers(ServerInfos()), mServerInfo(serverInfo) { setWindowName("ServerDialog"); loadCustomServers(); mServersListModel = new ServersListModel(&mServers, this); mServersList = new ServersListBox(mServersListModel); ScrollArea *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mDescription = new Label(std::string()); mDownloadText = new Label(std::string()); mQuitButton = new Button(_("Quit"), "quit", this); mConnectButton = new Button(_("Connect"), "connect", this); mManualEntryButton = new Button(_("Add custom Server..."), "addEntry", this); mModifyButton = new Button(_("Modify..."), "modify", this); mDeleteButton = new Button(_("Delete"), "remove", this); mServersList->setActionEventId("connect"); mServersList->addSelectionListener(this); usedScroll->setVerticalScrollAmount(0); place(0, 0, usedScroll, 6, 5).setPadding(3); place(0, 5, mDescription, 5); place(0, 6, mDownloadText, 5); place(0, 7, mManualEntryButton); place(1, 7, mModifyButton); place(2, 7, mDeleteButton); place(4, 7, mQuitButton); place(5, 7, mConnectButton); // Make sure the list has enough height getLayout().setRowHeight(3, 80); // Do this manually instead of calling reflowLayout so we can enforce a // minimum width. int width = 0, height = 0; getLayout().reflow(width, height); if (width < 400) { width = 400; getLayout().reflow(width, height); } setContentSize(width, height); setMinWidth(getWidth()); setMinHeight(getHeight()); setDefaultSize(getWidth(), getHeight(), ImageRect::CENTER); setResizable(true); addKeyListener(this); loadWindowState(); mServersList->setSelected(0); // Do this after for the Delete button setVisible(true); mServersList->requestFocus(); downloadServerList(); }
void SkillDialog::loadSkills(const std::string &file) { // TODO: mTabs->clear(); while (mTabs->getSelectedTabIndex() != -1) { mTabs->removeTabWithIndex(mTabs->getSelectedTabIndex()); } for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); it++) { delete (*it).second->display; } delete_all(mSkills); mSkills.clear(); if (file.length() == 0) return; XML::Document doc(file); xmlNodePtr root = doc.rootNode(); if (!root || !xmlStrEqual(root->name, BAD_CAST "skills")) { logger->log("Error loading skills file: %s", file.c_str()); return; } int setCount = 0; std::string setName; ScrollArea *scroll; VertContainer *container; for_each_xml_child_node(set, root) { if (xmlStrEqual(set->name, BAD_CAST "set")) { setCount++; setName = XML::getProperty(set, "name", strprintf(_("Skill Set %d"), setCount)); container = new VertContainer(32); container->setOpaque(false); scroll = new ScrollArea(container); scroll->setOpaque(false); scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); mTabs->addTab(setName, scroll); for_each_xml_child_node(node, set) { if (xmlStrEqual(node->name, BAD_CAST "skill")) { int id = atoi(XML::getProperty(node, "id", "-1").c_str()); std::string name = XML::getProperty(node, "name", strprintf(_("Skill %d"), id)); std::string icon = XML::getProperty(node, "icon", ""); SkillInfo *skill = new SkillInfo; skill->id = id; skill->name = name; skill->icon = icon; skill->modifiable = 0; skill->display = new SkillEntry(skill); container->add(skill->display); mSkills[id] = skill; } } } }
Setup_Video::Setup_Video(): mFullScreenEnabled(config.getValue("screen", false)), mOpenGLEnabled(config.getValue("opengl", false)), mCustomCursorEnabled(config.getValue("customcursor", true)), mNameEnabled(config.getValue("showownname", false)), mPickupChatEnabled(config.getValue("showpickupchat", true)), mPickupParticleEnabled(config.getValue("showpickupparticle", false)), mOpacity(config.getValue("guialpha", 0.8)), mMouseOpacity(config.getValue("mousealpha", 0.7)), mFps((int) config.getValue("fpslimit", 0)), mSpeechMode((int) config.getValue("speech", 3)), mScreenWidth(graphics->getWidth()), mScreenHeight(graphics->getHeight()), mModeListModel(new ModeListModel), mModeList(new ListBox(mModeListModel, "videomode", this)), mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)), mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)), mNameCheckBox(new CheckBox(_("Show name"), mNameEnabled)), mSpeechSlider(new Slider(0, 3)), mSpeechModeLabel(new Label("")), mAlphaSlider(new Slider(0.2, 1.0)), mMouseAlphaSlider(new Slider(0.2, 1.0)), mFpsCheckBox(new CheckBox(_("FPS Limit:"))), mFpsSlider(new Slider(5, 200)), mFpsField(new TextField), mFontSize((int) config.getValue("fontSize", 11)), mFontSizeSlider(new Slider(8, 14)), mFontSizeLabel(new Label("")), mOverlayDetail((int) config.getValue("OverlayDetail", 2)), mOverlayDetailSlider(new Slider(0, 2)), mOverlayDetailLabel(new Label("")), mParticleDetail(3 - (int) config.getValue("particleEmitterSkip", 1)), mParticleDetailSlider(new Slider(-1, 3)), mParticleDetailLabel(new Label("")), mPickupNotifyLabel(new Label(_("Show pickup notification"))), mPickupChatCheckBox(new CheckBox(_("in chat"), mPickupChatEnabled)), mPickupParticleCheckBox(new CheckBox(_("as particle"), mPickupParticleEnabled)) { setName(_("Video")); ScrollArea *scrollArea = new ScrollArea(mModeList); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setWidth(90); speechLabel = new Label(_("Overhead text")); alphaLabel = new Label(_("Gui opacity")); mouseAlphaLabel = new Label(_("Mouse opacity")); fontSizeLabel = new Label(_("Font size")); overlayDetailLabel = new Label(_("Ambient FX")); particleDetailLabel = new Label(_("Particle detail")); mModeList->setEnabled(true); #ifndef USE_OPENGL mOpenGLCheckBox->setEnabled(false); #endif mAlphaSlider->setValue(mOpacity); mMouseAlphaSlider->setValue(mMouseOpacity); mFpsField->setText(toString(mFps)); mFpsField->setWidth(30); mFpsField->setEnabled(false); mFpsSlider->setValue(mFps); mFpsSlider->setEnabled(mFps > 0); mFpsCheckBox->setSelected(mFps > 0); mCustomCursorCheckBox->setActionEventId("customcursor"); mPickupChatCheckBox->setActionEventId("pickupchat"); mPickupParticleCheckBox->setActionEventId("pickupparticle"); mNameCheckBox->setActionEventId("showownname"); mAlphaSlider->setActionEventId("guialpha"); mMouseAlphaSlider->setActionEventId("mousealpha"); mFpsCheckBox->setActionEventId("fpslimitcheckbox"); mSpeechSlider->setActionEventId("speech"); mFpsSlider->setActionEventId("fpslimitslider"); mFontSizeSlider->setActionEventId("fontsizeslider"); mOverlayDetailSlider->setActionEventId("overlaydetailslider"); mParticleDetailSlider->setActionEventId("particledetailslider"); mCustomCursorCheckBox->addActionListener(this); mPickupChatCheckBox->addActionListener(this); mPickupParticleCheckBox->addActionListener(this); mNameCheckBox->addActionListener(this); mAlphaSlider->addActionListener(this); mMouseAlphaSlider->addActionListener(this); mFpsCheckBox->addActionListener(this); mSpeechSlider->addActionListener(this); mFpsSlider->addActionListener(this); mFontSizeSlider->addActionListener(this); mOverlayDetailSlider->addActionListener(this); mParticleDetailSlider->addActionListener(this); setSpeechModeLabel(mSpeechMode); mSpeechSlider->setValue(mSpeechMode); mFontSize = (int) config.getValue("fontSize", 11); mFontSizeLabel->setCaption(strprintf(_("%d Point"), mFontSize)); mFontSizeSlider->setValue(mFontSize); setOverlayDetailLabel(mOverlayDetail); mOverlayDetailSlider->setValue(mOverlayDetail); setParticleDetailLabel(mParticleDetail); mParticleDetailSlider->setValue(mParticleDetail); mFpsSlider->setStepLength(1.0); mFontSizeSlider->setStepLength(1.0); mSpeechSlider->setStepLength(1.0); mOverlayDetailSlider->setStepLength(1.0); mParticleDetailSlider->setStepLength(1.0); // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, scrollArea, 1, 6).setPadding(2); place(1, 0, mFsCheckBox, 2); place(3, 0, mOpenGLCheckBox, 1); place(1, 1, mCustomCursorCheckBox, 3); place(1, 2, mNameCheckBox, 3); place(1, 3, mPickupNotifyLabel, 3); place(1, 4, mPickupChatCheckBox, 1); place(2, 4, mPickupParticleCheckBox, 2); place(0, 6, mAlphaSlider); place(0, 7, mMouseAlphaSlider); place(0, 8, mFpsSlider); place(0, 9, mFontSizeSlider); place(0, 10, mSpeechSlider); place(0, 11, mOverlayDetailSlider); place(0, 12, mParticleDetailSlider); place(1, 6, alphaLabel, 3).setPadding(2); place(1, 7, mouseAlphaLabel, 3).setPadding(2); place(1, 8, mFpsCheckBox).setPadding(3); place(1, 9, fontSizeLabel); place(1, 10, speechLabel); place(1, 11, overlayDetailLabel); place(1, 12, particleDetailLabel); place(2, 8, mFpsField).setPadding(1); place(2, 9, mFontSizeLabel, 3).setPadding(2); place(2, 10, mSpeechModeLabel, 3).setPadding(2); place(2, 11, mOverlayDetailLabel, 3).setPadding(2); place(2, 12, mParticleDetailLabel, 3).setPadding(2); setDimension(gcn::Rectangle(0, 0, 325, 280)); }
/** 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); }