void pawsScrollBar::OnResize() { SetThumbVisibility(); if(thumb && thumb->IsVisible()) SetThumbLayout(); SetButtonLayout(); }
bool pawsScrollBar::PostSetup() { // Create the scroll up/left button upButton = new pawsButton; upButton->SetParent(this); int flags; if(!horizontal) { flags = ATTACH_TOP | ATTACH_RIGHT; if(upUnpressed.IsEmpty()) upUnpressed = "Up Arrow"; if(upPressed.IsEmpty()) upPressed = "Up Arrow"; } else { flags = ATTACH_LEFT | ATTACH_BOTTOM; if(upUnpressed.IsEmpty()) upUnpressed = "Left Arrow"; if(upPressed.IsEmpty()) upPressed = "Left Arrow"; } upButton->SetUpImage(upUnpressed); upButton->SetDownImage(upPressed); if(!upGrey.IsEmpty()) { upButton->SetGreyUpImage(upGrey); upButton->SetGreyDownImage(upGrey); } //Add the sound upButton->SetSound(SCROLL_UP_SND); upButton->SetAttachFlags(flags); upButton->SetID(SCROLL_UP); AddChild(upButton); // Create the scroll down button. downButton = new pawsButton; downButton->SetParent(this); if(!horizontal) { flags = ATTACH_BOTTOM | ATTACH_RIGHT; if(downUnpressed.IsEmpty()) downUnpressed = "Down Arrow"; if(downPressed.IsEmpty()) downPressed = "Down Arrow"; } else { flags = ATTACH_RIGHT | ATTACH_BOTTOM; if(downUnpressed.IsEmpty()) downUnpressed = "Right Arrow"; if(downPressed.IsEmpty()) downPressed = "Right Arrow"; } downButton->SetUpImage(downUnpressed); downButton->SetDownImage(downPressed); if(!downGrey.IsEmpty()) { downButton->SetGreyUpImage(downGrey); downButton->SetGreyDownImage(downGrey); } //Add the sound downButton->SetSound(SCROLL_DOWN_SND); downButton->SetAttachFlags(flags); downButton->SetID(SCROLL_DOWN); AddChild(downButton); SetButtonLayout(); thumb = new pawsThumb(); AddChild(thumb); thumb->SetBackground(thumbStopped); thumb->SetID(SCROLL_THUMB); SetThumbVisibility(); if(thumb->IsVisible()) SetThumbLayout(); return true; }
bool EngineStatePoolGameSelect::Load() { if (!EngineStateText::Load()) { return false; } std::string bg = GetEngine()->GetConfigValue("title_bg"); if (!m_bg.Load(bg, "")) { return false; } m_pOnePlayerButton = new PoolGuiButton; std::string onePlayerFile = GetEngine()->GetConfigValue("golf_1p_button"); if (!m_pOnePlayerButton->Load(onePlayerFile)) { ReportError("Failed to load one player button."); return false; } static const float y = Engine::Instance()->GetConfigFloat("golf_gs_b_y"); // static const float x2 = Engine::Instance()->GetConfigFloat("golf_gs_b_x2"); static const float SIZE_W = Engine::Instance()->GetConfigFloat( "pool_main_button_w"); static const float SIZE_H = Engine::Instance()->GetConfigFloat( "pool_main_button_h"); static const float SPACE_H = Engine::Instance()->GetConfigFloat( "pool_main_button_h_space"); static const float x1 = 12.5f - 0.5f * SIZE_W; SetButtonLayout(m_pOnePlayerButton, "1player"); // m_pOnePlayerButton->SetSize(SIZE_W, SIZE_H); // m_pOnePlayerButton->SetRelPos(y + SPACE_H, x1); m_pOnePlayerButton->SetCommand(&OnOnePlayer); m_pTwoPlayerButton = new PoolGuiButton; std::string twoPlayerFile = GetEngine()->GetConfigValue("golf_2p_button"); if (!m_pTwoPlayerButton->Load(twoPlayerFile)) { ReportError("Failed to load two player button."); return false; } SetButtonLayout(m_pTwoPlayerButton, "2player"); // m_pTwoPlayerButton->SetSize(SIZE_W, SIZE_H); // m_pTwoPlayerButton->SetRelPos(y + SPACE_H * 2.0f, x1); m_pTwoPlayerButton->SetCommand(&OnTwoPlayer); m_pOnePlayerPractiseButton = new PoolGuiButton; std::string practiseFile = GetEngine()->GetConfigValue("pool_prac_button"); if (!m_pOnePlayerPractiseButton->Load(practiseFile)) { ReportError("Failed to load one player practise button."); return false; } SetButtonLayout(m_pOnePlayerPractiseButton, "1playerprac"); // m_pOnePlayerPractiseButton->SetSize(SIZE_W, SIZE_H); // m_pOnePlayerPractiseButton->SetRelPos(y, x1); m_pOnePlayerPractiseButton->SetCommand(&OnOnePlayerPractise); m_pTwoPlayerOnlineButton = new PoolGuiButton; std::string twoPlayerOnlineFile = GetEngine()->GetConfigValue("pool_2p_online_button"); if (!m_pTwoPlayerOnlineButton->Load(twoPlayerOnlineFile)) { ReportError("Failed to load two player online button."); return false; } SetButtonLayout(m_pTwoPlayerOnlineButton, "2playeronline"); // m_pTwoPlayerOnlineButton->SetSize(SIZE_W, SIZE_H); // m_pTwoPlayerOnlineButton->SetRelPos(y + SPACE_H * 3.0f, x1); m_pTwoPlayerOnlineButton->SetCommand(&OnTwoPlayerOnline); m_pQuitButton = new PoolGuiButton; std::string menuQuitFile = GetEngine()->GetConfigValue("menu_quit_button"); if (!m_pQuitButton->Load(menuQuitFile)) { ReportError("Failed to load menu quit button."); return false; } SetButtonLayout(m_pQuitButton, "quit"); // m_pQuitButton->SetSize(SIZE_W, SIZE_H); // m_pQuitButton->SetRelPos(y + SPACE_H * 5.0f, x1); m_pQuitButton->SetCommand(&OnExitClicked); // TODO + confirm ? m_pOptionsButton = new PoolGuiButton; if (!m_pOptionsButton->Load("menu-options-button.txt")) { ReportError("Failed to load main menu options button"); return false; } SetButtonLayout(m_pOptionsButton, "options"); // m_pOptionsButton->SetSize(SIZE_W, SIZE_H); // m_pOptionsButton->SetRelPos(y + SPACE_H * 3.0f, x1); m_pOptionsButton->SetCommand(&OnOptions); m_pEditNamesButton = new PoolGuiButton; if (!m_pEditNamesButton->Load("menu-edit-names-button.txt")) { ReportError("Failed to load main menu edit names button"); return false; } SetButtonLayout(m_pEditNamesButton, "editnames"); // m_pEditNamesButton->SetSize(SIZE_W, SIZE_H); // m_pEditNamesButton->SetRelPos(y + SPACE_H * 4.0f, x1); m_pEditNamesButton->SetCommand(&OnEditNames); // "Register" button m_pRegButton = new PoolGuiButton; if (!m_pRegButton->Load("menu-reg-button.txt")) { return false; } m_pRegButton->SetSize(SIZE_W, SIZE_H); m_pRegButton->SetRelPos(y + SPACE_H * 7.0f, x1); m_pRegButton->SetCommand(&OnRegisterClicked); // Buy now button m_pBuyButton = new PoolGuiButton; if (!m_pBuyButton->Load("menu-buy-button.txt")) { return false; } m_pBuyButton->SetSize(SIZE_W, SIZE_H); m_pBuyButton->SetRelPos(y + SPACE_H * 6.0f, x1); m_pBuyButton->SetCommand(&OnBuyButton); return true; }