void LoadingProgress::PaintBackground() { int screenWide, screenTall; surface()->GetScreenSize( screenWide, screenTall ); if ( m_bDrawBackground && m_pBGImage ) { int x, y, wide, tall; m_pBGImage->GetBounds( x, y, wide, tall ); surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pBGImage->GetImage()->GetID() ); surface()->DrawTexturedRect( x, y, x+wide, y+tall ); } if ( m_bDrawPoster && m_pPoster && m_pPoster->GetImage() ) { if ( m_bFullscreenPoster ) { surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pPoster->GetImage()->GetID() ); surface()->DrawTexturedRect( 0, 0, screenWide, screenTall ); } else { // fill black surface()->DrawSetColor( Color( 0, 0, 0, 255 ) ); surface()->DrawFilledRect( 0, 0, screenWide, screenTall ); // overlay poster int x, y, wide, tall; m_pPoster->GetBounds( x, y, wide, tall ); surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pPoster->GetImage()->GetID() ); surface()->DrawTexturedRect( x, y, x+wide, y+tall ); } } if ( m_bDrawPoster && m_pFooter ) { int screenWidth, screenHeight; CBaseModPanel::GetSingleton().GetSize( screenWidth, screenHeight ); int x, y, wide, tall; m_pFooter->GetBounds( x, y, wide, tall ); surface()->DrawSetColor( m_pFooter->GetBgColor() ); surface()->DrawFilledRect( 0, y, x+screenWidth, y+tall ); } // this is where the spinner draws bool bRenderSpinner = ( m_bDrawSpinner && m_pWorkingAnim ); Panel *pWaitscreen = CBaseModPanel::GetSingleton().GetWindow( WT_GENERICWAITSCREEN ); if ( pWaitscreen && pWaitscreen->IsVisible() && ( m_LoadingWindowType == LWT_BKGNDSCREEN ) ) bRenderSpinner = false; // Don't render spinner if the progress screen is displaying progress if ( bRenderSpinner ) { int x, y, wide, tall; wide = tall = scheme()->GetProportionalScaledValue( 45 ); x = scheme()->GetProportionalScaledValue( 45 ) - wide/2; y = screenTall - scheme()->GetProportionalScaledValue( 32 ) - tall/2; m_pWorkingAnim->GetImage()->SetFrame( m_pWorkingAnim->GetFrame() ); surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); surface()->DrawSetTexture( m_pWorkingAnim->GetImage()->GetID() ); surface()->DrawTexturedRect( x, y, x+wide, y+tall ); } if ( m_bDrawProgress && m_pProTotalProgress ) { int x, y, wide, tall; m_pProTotalProgress->GetBounds( x, y, wide, tall ); int iScreenWide, iScreenTall; surface()->GetScreenSize( iScreenWide, iScreenTall ); float f = m_pProTotalProgress->GetProgress(); f = clamp( f, 0, 1.0f ); // Textured bar surface()->DrawSetColor( Color( 255, 255, 255, 255 ) ); // Texture BG surface()->DrawSetTexture( m_textureID_LoadingBarBG ); surface()->DrawTexturedRect( x, y, x + wide, y + tall ); surface()->DrawSetTexture( m_textureID_LoadingBar ); // YWB 10/13/2009: If we don't crop the texture coordinate down then we will see a jitter of the texture as the texture coordinate and the rounded width // alias int nIntegerWide = f * wide; float flUsedFrac = (float)nIntegerWide / (float)wide; DrawTexturedRectParms_t params; params.x0 = x; params.y0 = y; params.x1 = x + nIntegerWide; params.y1 = y + tall; params.s0 = 0; params.s1 = flUsedFrac; surface()->DrawTexturedRectEx( ¶ms ); } // Need to call this periodically to collect sign in and sign out notifications, // do NOT dispatch events here in the middle of loading and rendering! if ( ThreadInMainThread() ) { XBX_ProcessEvents(); } }
//----------------------------------------------------------------------------- // Purpose: respond to cursor movments //----------------------------------------------------------------------------- bool BuildGroup::CursorMoved(int x, int y, Panel *panel) { Assert(panel); if ( !m_hBuildDialog.Get() ) { if ( panel->GetParent() ) { EditablePanel *ep = dynamic_cast< EditablePanel * >( panel->GetParent() ); if ( ep ) { BuildGroup *bg = ep->GetBuildGroup(); if ( bg && bg != this ) { bg->CursorMoved( x, y, panel ); } } } return false; } // no moving uneditable panels // commented out because this has issues with panels moving // to front and obscuring other panels //if (!panel->IsBuildModeEditable()) // return; if (_dragging) { input()->GetCursorPos(x, y); if (_dragMouseCode == MOUSE_RIGHT) { int newW = max( 1, _dragStartPanelSize[ 0 ] + x - _dragStartCursorPos[0] ); int newH = max( 1, _dragStartPanelSize[ 1 ] + y - _dragStartCursorPos[1] ); bool shift = ( input()->IsKeyDown(KEY_LSHIFT) || input()->IsKeyDown(KEY_RSHIFT) ); bool ctrl = ( input()->IsKeyDown(KEY_LCONTROL) || input()->IsKeyDown(KEY_RCONTROL) ); if ( shift ) { newW = _dragStartPanelSize[ 0 ]; } if ( ctrl ) { newH = _dragStartPanelSize[ 1 ]; } panel->SetSize( newW, newH ); ApplySnap(panel); } else { for (int i=0; i < _controlGroup.Count(); ++i) { // now fix offset of member panels with respect to the one we are dragging Panel *groupMember = _controlGroup[i].Get(); groupMember->SetPos(_dragStartPanelPos[0] + _groupDeltaX[i] +(x-_dragStartCursorPos[0]), _dragStartPanelPos[1] + _groupDeltaY[i] +(y-_dragStartCursorPos[1])); ApplySnap(groupMember); } } // update the build dialog if (m_hBuildDialog) { KeyValues *keyval = new KeyValues("UpdateControlData"); keyval->SetPtr("panel", GetCurrentPanel()); ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), keyval, NULL); keyval = new KeyValues("EnableSaveButton"); ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), keyval, NULL); } panel->Repaint(); panel->CallParentFunction(new KeyValues("Repaint")); } return true; }
void add() { Panel add ; Panel scribble; add.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN); add.show(); add.shape("ADD"); get_current_settings( ); cmpna(); Panel move; move.init(220,120,525,455,OUT,THIN); move.show( ); move.shape("ADD"); cmpad(); move.init(220,120,525,455,OUT,THIN); move.show( ); move.shape("ADD"); scribble.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN); scribble.show(); add.show(); add.shape("ADD"); passins(); move.init(220,120,525,455,OUT,THIN); move.show( ); move.shape("ADD"); taxation(); move.init(220,120,525,455,OUT,THIN); move.show( ); move.shape("ADD"); runner(); int cnt=0; cnt++; scribble.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN); scribble.show(); }
void CFolderMenu::Update() { ReloadControlSettings(false, false); MoveToCenterOfScreen(); Button *entry = dynamic_cast<Button *>(FindChildByName("ApproveButton")); if (entry) entry->SetVisible(true); C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (!pPlayer) return; if (pPlayer->HasCharacterBeenChosen()) Q_strcpy(m_szCharacter, pPlayer->GetCharacter()); else m_szCharacter[0] = '\0'; if (ShouldShowCharacterOnly() && !ShouldShowTeams()) { m_pProfileInfo->SetVisible(true); if (m_szPreviewCharacter[0]) m_pProfileInfo->SetText((std::string("#DA_CharacterInfo_") + m_szPreviewCharacter).c_str()); else if (m_szCharacter[0]) m_pProfileInfo->SetText((std::string("#DA_CharacterInfo_") + m_szCharacter).c_str()); else m_pProfileInfo->SetText("#DA_CharacterInfo_None"); } else m_pProfileInfo->SetVisible(false); CFolderLabel *pCharacterName = dynamic_cast<CFolderLabel *>(FindChildByName("AgentName")); if (pCharacterName) { if (!ShouldShowTeams()) { std::string sCharacter; if (m_szPreviewCharacter[0]) sCharacter = std::string("#DA_Character_") + m_szPreviewCharacter; else if (m_szCharacter[0]) sCharacter = std::string("#DA_Character_") + m_szCharacter; std::wstring sLocalized; wchar_t* pszLocalized = g_pVGuiLocalize->Find( sCharacter.c_str() ); if (pszLocalized) sLocalized += pszLocalized; if (pPlayer->m_Shared.m_iStyleSkillAfterRespawn) { std::string sSkill = std::string("#DA_Skill_") + SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkillAfterRespawn.Get()) + "_Adjective"; pszLocalized = g_pVGuiLocalize->Find( sSkill.c_str() ); if (pszLocalized) sLocalized += pszLocalized; } pCharacterName->SetText(sLocalized.c_str()); } else pCharacterName->SetText(""); } CFolderLabel* pLabels[2]; pLabels[0] = dynamic_cast<CFolderLabel *>(FindChildByName("RequestedArmament1")); pLabels[1] = dynamic_cast<CFolderLabel *>(FindChildByName("RequestedArmament2")); int iArmamentsOn1 = 0; std::wostringstream sLabel1; std::wostringstream sLabel2; SDKWeaponID eFirst = WEAPON_NONE; for (int i = 0; i < MAX_LOADOUT; i++) { if (!pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i)) continue; CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i); if (!pWeaponInfo) continue; if (!eFirst) { eFirst = (SDKWeaponID)i; if (pPlayer->GetLoadoutWeaponCount(eFirst) > 1) { CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo(eFirst); if (pWeaponInfo && pWeaponInfo->m_szAkimbo[0]) { // If we have two of this weapon and this weapon has an akimbo, use the akimbo instead. eFirst = AliasToWeaponID(pWeaponInfo->m_szAkimbo); } } } else { if (pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) > 1) { CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i); if (pWeaponInfo && pWeaponInfo->m_szAkimbo[0]) { SDKWeaponID eAkimbo = AliasToWeaponID(pWeaponInfo->m_szAkimbo); if (eAkimbo < eFirst) { // If we have this akimbo and it's preferred to the current weapon, use it instead. // (Preferred means lower weapon ID.) eFirst = eAkimbo; } } } } std::wostringstream sLabel; const wchar_t *pchFmt = g_pVGuiLocalize->Find( pWeaponInfo->szPrintName ); if ( pchFmt && pchFmt[0] ) sLabel << pchFmt; else sLabel << pWeaponInfo->szPrintName; if (pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) > 1) sLabel << " x" << pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) << "\n"; else sLabel << "\n"; if (iArmamentsOn1 >= 2) sLabel2 << sLabel.str(); else sLabel1 << sLabel.str(); iArmamentsOn1++; } if (pLabels[0]) pLabels[0]->SetText(sLabel1.str().c_str()); if (pLabels[1]) pLabels[1]->SetText(sLabel2.str().c_str()); const char szPlayerPreviewTemplate[] = " \"model\"\n" " {\n" " \"spotlight\" \"1\"\n" " \"modelname\" \"models/player/frank.mdl\"\n" " \"origin_z\" \"-57\"\n" " \"origin_y\" \"10\"\n" " \"origin_x\" \"110\"\n" " \"angles_y\" \"180\"\n" " \"animation\"\n" " {\n" " \"sequence\" \"m1911_idle\"\n" " \"pose_parameters\"\n" " {\n" " \"body_yaw\" \"25.0\"\n" " \"body_pitch\" \"-30.0\"\n" " }\n" " }\n" " \"attached_model\"\n" " {\n" " \"modelname\" \"models/weapons/m1911.mdl\"\n" " }\n" " }"; CModelPanel *pPlayerPreview = dynamic_cast<CModelPanel *>(FindChildByName("player_preview")); CSDKWeaponInfo* pWeaponInfo = NULL; if (eFirst) pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo(eFirst); if ((m_szCharacter[0] || m_szPreviewCharacter[0]) && pPlayerPreview && !ShouldShowTeams()) { KeyValues* pValues = new KeyValues("preview"); pValues->LoadFromBuffer("model", szPlayerPreviewTemplate); const char* pCharacter = m_szCharacter; if (m_szPreviewCharacter[0]) pCharacter = m_szPreviewCharacter; pValues->SetString("modelname", VarArgs("models/player/%s.mdl", pCharacter)); if (ShouldShowCharacterOnly() || ShouldShowCharacterAndWeapons()) { pValues->SetFloat("origin_x", hud_characterpreview_x.GetFloat()); pValues->SetFloat("origin_y", hud_characterpreview_y.GetFloat()); pValues->SetFloat("origin_z", hud_characterpreview_z.GetFloat()); } else { pValues->SetFloat("origin_x", hud_playerpreview_x.GetFloat()); pValues->SetFloat("origin_y", hud_playerpreview_y.GetFloat()); pValues->SetFloat("origin_z", hud_playerpreview_z.GetFloat()); } if (m_pPage && FStrEq(m_pPage->GetName(), "class") && m_szPreviewSequence[0] && m_szPreviewWeaponModel[0] && !pPlayer->GetLoadoutWeight()) { KeyValues* pAnimation = pValues->FindKey("animation"); if (pAnimation) pAnimation->SetString("sequence", m_szPreviewSequence); KeyValues* pWeapon = pValues->FindKey("attached_model"); if (pWeapon) pWeapon->SetString("modelname", m_szPreviewWeaponModel); } else if (pWeaponInfo) { KeyValues* pAnimation = pValues->FindKey("animation"); if (pAnimation) pAnimation->SetString("sequence", VarArgs("%s_idle", WeaponIDToAlias(eFirst))); KeyValues* pWeapon = pValues->FindKey("attached_model"); if (pWeapon) pWeapon->SetString("modelname", pWeaponInfo->szWorldModel); } else { KeyValues* pAnimation = pValues->FindKey("animation"); if (pAnimation) pAnimation->SetString("sequence", "idle"); KeyValues* pWeapon = pValues->FindKey("attached_model"); if (pWeapon) pWeapon->SetString("modelname", ""); } if (SDKGameRules()->IsTeamplay()) { if (pPlayer->GetTeamNumber() == SDK_TEAM_BLUE) pValues->SetInt("skin", 1); else if (pPlayer->GetTeamNumber() == SDK_TEAM_RED) pValues->SetInt("skin", 2); else pValues->SetInt("skin", 0); } else pValues->SetInt("skin", 0); pPlayerPreview->ParseModelInfo(pValues); pValues->deleteThis(); } else if (pPlayerPreview) pPlayerPreview->SwapModel(""); for ( int i = 0; i < m_apWeaponIcons.Count(); i++) { if (m_apWeaponIcons[i].m_pWeaponName) m_apWeaponIcons[i].m_pWeaponName->DeletePanel(); if (m_apWeaponIcons[i].m_pSlots) m_apWeaponIcons[i].m_pSlots->DeletePanel(); if (m_apWeaponIcons[i].m_pImage) m_apWeaponIcons[i].m_pImage->DeletePanel(); if (m_apWeaponIcons[i].m_pDelete) m_apWeaponIcons[i].m_pDelete->DeletePanel(); } m_apWeaponIcons.RemoveAll(); const char szWeaponPreviewTemplate[] = " \"model\"\n" " {\n" " \"spotlight\" \"1\"\n" " \"modelname\" \"models/weapons/beretta.mdl\"\n" " \"origin_x\" \"30\"\n" " \"origin_y\" \"3\"\n" " \"origin_z\" \"-3\"\n" " \"angles_y\" \"200\"\n" " }"; Panel *pWeaponIconArea = FindChildByName("WeaponIconArea"); if ((ShouldShowCharacterAndWeapons() || ShouldShowEverything()) && pWeaponIconArea) { int iWeaponAreaX, iWeaponAreaY, iWeaponAreaW, iWeaponAreaH; pWeaponIconArea->GetPos(iWeaponAreaX, iWeaponAreaY); pWeaponIconArea->GetSize(iWeaponAreaW, iWeaponAreaH); int iMargin = 5; int iBoxSize = (iWeaponAreaW-5)/2; int iWeapon = 0; for (int i = 0; i < MAX_LOADOUT; i++) { if (!pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i)) continue; CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i); if (!pWeaponInfo) continue; for (int j = 0; j < pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i); j++) { float flMoveRight = 0; if (iWeapon%2 == 1) flMoveRight = iBoxSize + iMargin; CWeaponIcon* pIcon = &m_apWeaponIcons[m_apWeaponIcons.AddToTail()]; pIcon->m_pWeaponName = new CFolderLabel(this, NULL); pIcon->m_pWeaponName->SetText(VarArgs("#DA_Weapon_Obituary_%s", pWeaponInfo->szClassName+7)); // Use the obit version because it's shorter pIcon->m_pWeaponName->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + 10 + (iWeapon/2) * (iBoxSize+iMargin)); pIcon->m_pWeaponName->SetSize(iBoxSize, 15); pIcon->m_pWeaponName->SetContentAlignment(Label::a_center); pIcon->m_pWeaponName->SetZPos(-5); pIcon->m_pWeaponName->SetFont(vgui::scheme()->GetIScheme(GetScheme())->GetFont("FolderLarge")); pIcon->m_pWeaponName->SetScheme("FolderScheme"); std::wostringstream sSlotsLabel; if (pWeaponInfo->iWeight) { const wchar_t *pchFmt = g_pVGuiLocalize->Find( "#DA_BuyMenu_Weapon_Slots" ); if ( pchFmt && pchFmt[0] ) sSlotsLabel << pchFmt; else sSlotsLabel << "Slots: "; sSlotsLabel << pWeaponInfo->iWeight; pIcon->m_pSlots = new CFolderLabel(this, NULL); pIcon->m_pSlots->SetText(sSlotsLabel.str().c_str()); pIcon->m_pSlots->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + iBoxSize - 10 + (iWeapon/2) * (iBoxSize+iMargin)); pIcon->m_pSlots->SetSize(iBoxSize, 15); pIcon->m_pSlots->SetContentAlignment(Label::a_center); pIcon->m_pSlots->SetZPos(-5); pIcon->m_pSlots->SetFont(vgui::scheme()->GetIScheme(GetScheme())->GetFont("FolderSmall")); pIcon->m_pSlots->SetScheme("FolderScheme"); } KeyValues* pValues = new KeyValues("preview"); pValues->LoadFromBuffer("model", szWeaponPreviewTemplate); pValues->SetString("modelname", pWeaponInfo->szWorldModel); if (pWeaponInfo->m_eWeaponType == WT_PISTOL) pIcon->m_flDistance = 20; else if (pWeaponInfo->m_eWeaponType == WT_RIFLE) pIcon->m_flDistance = 50; else if (pWeaponInfo->m_eWeaponType == WT_SHOTGUN) pIcon->m_flDistance = 50; else if (pWeaponInfo->m_eWeaponType == WT_SMG) pIcon->m_flDistance = 30; else if (pWeaponInfo->m_eWeaponType == WT_GRENADE) pIcon->m_flDistance = 20; pIcon->m_pImage = new CModelPanel(this, NULL); pIcon->m_pImage->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + (iWeapon/2) * (iBoxSize+iMargin)); pIcon->m_pImage->SetSize(iBoxSize, iBoxSize); pIcon->m_pImage->SetZPos(-15); pIcon->m_pImage->SetScheme("FolderScheme"); pIcon->m_pImage->ParseModelInfo(pValues); pValues->deleteThis(); pIcon->m_pDelete = new CImageButton(this, VarArgs("delete_%d", iWeapon)); pIcon->m_pDelete->SetDimensions(iWeaponAreaX + iBoxSize - 8 + flMoveRight, iWeaponAreaY + 30 + (iWeapon/2) * (iBoxSize+iMargin), 12, 12); pIcon->m_pDelete->SetZPos(15); pIcon->m_pDelete->SetImage("folder_delete"); pIcon->m_pDelete->SetPaintBorderEnabled(false); pIcon->m_pDelete->SetPaintBackgroundEnabled(true); pIcon->m_pDelete->SetCommand(VarArgs("buy remove %d", i)); iWeapon++; } } } CFolderLabel* pWeaponTotalWeightNumber = dynamic_cast<CFolderLabel*>(FindChildByName("WeaponTotalWeightNumber")); CFolderLabel* pWeaponTotalWeight = dynamic_cast<CFolderLabel*>(FindChildByName("WeaponTotalWeight")); if ((ShouldShowCharacterAndWeapons() || ShouldShowEverything()) && pPlayer->GetLoadoutWeight()) { if (pWeaponTotalWeightNumber) { wchar_t szText[20]; _snwprintf( szText, ARRAYSIZE(szText) - 1, L"%d/%d", pPlayer->GetLoadoutWeight(), MAX_LOADOUT_WEIGHT ); pWeaponTotalWeightNumber->SetText(szText); pWeaponTotalWeightNumber->SetVisible(true); } if (pWeaponTotalWeight) pWeaponTotalWeight->SetVisible(true); } else { if (pWeaponTotalWeightNumber) pWeaponTotalWeightNumber->SetVisible(false); if (pWeaponTotalWeight) pWeaponTotalWeight->SetVisible(false); } if (ShouldShowEverything()) { CFolderLabel *pSkillInfo = dynamic_cast<CFolderLabel *>(FindChildByName("SkillInfo")); CPanelTexture *pSkillIcon = dynamic_cast<CPanelTexture *>(FindChildByName("SkillIcon")); if (pSkillInfo && pSkillIcon) { if (pPlayer->m_Shared.m_iStyleSkillAfterRespawn) { pSkillInfo->SetText((std::string("#DA_SkillInfo_") + SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkillAfterRespawn.Get())).c_str()); pSkillIcon->SetImage(SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkillAfterRespawn.Get())); } else { pSkillInfo->SetText(""); pSkillIcon->SetImage(""); } } } m_pSuicideOption->SetVisible(pPlayer->IsAlive() && !ShouldShowTeams()); Button *pProceedButton = dynamic_cast<Button *>(FindChildByName("ProceedButton")); if (pProceedButton) pProceedButton->SetVisible(m_pPage && FStrEq(m_pPage->GetName(), PANEL_BUY)); Button *pApproveButton = dynamic_cast<Button *>(FindChildByName("ApproveButton")); if (pApproveButton) pApproveButton->SetVisible(IsLoadoutComplete()); Button *pAgentsTab = dynamic_cast<Button *>(FindChildByName("AgentsTab")); if (pAgentsTab) pAgentsTab->SetVisible(pPlayer->HasCharacterBeenChosen()); Button *pWeaponsTab = dynamic_cast<Button *>(FindChildByName("WeaponsTab")); if (pWeaponsTab) pWeaponsTab->SetVisible(pPlayer->HasCharacterBeenChosen()); Button *pSkillsTab = dynamic_cast<Button *>(FindChildByName("SkillsTab")); if (pSkillsTab) pSkillsTab->SetVisible(pPlayer->HasSkillsTabBeenSeen()); Button *pChangeTeams = dynamic_cast<Button *>(FindChildByName("ChangeTeamsButton")); if (pChangeTeams) pChangeTeams->SetVisible(SDKGameRules()->IsTeamplay()); }
bool elevator::floor_is_valid(int f) const { return buttons.is_valid(f); }
//----------------------------------------------------------------------------- // Purpose: Sets the focus to the previous panel in the tab order // Input : *panel - panel currently with focus //----------------------------------------------------------------------------- bool FocusNavGroup::RequestFocusPrev(VPANEL panel) { if(panel==NULL) return false; _currentFocus = NULL; int newPosition = 9999999; if (panel) { newPosition = ipanel()->GetTabPosition(panel); } bool bFound = false; bool bRepeat = true; Panel *best = NULL; while (1) { newPosition--; if (newPosition > 0) { int bestPosition = 0; // look for the next tab position for (int i = 0; i < _mainPanel->GetChildCount(); i++) { Panel *child = _mainPanel->GetChild(i); if (child && child->IsVisible() && child->IsEnabled() && child->GetTabPosition()) { int tabPosition = child->GetTabPosition(); if (tabPosition == newPosition) { // we've found the right tab best = child; bestPosition = newPosition; // don't loop anymore since we've found the correct panel break; } else if (tabPosition < newPosition && tabPosition > bestPosition) { // record the match since this is the closest so far bestPosition = tabPosition; best = child; } } } if (!bRepeat) break; if (best) break; } else { // reset new position for next loop newPosition = 9999999; } // haven't found an item if (!_topLevelFocus) { // check to see if we should push the focus request up if (_mainPanel->GetVParent() && _mainPanel->GetVParent() != surface()->GetEmbeddedPanel()) { // we're not a top level panel, so forward up the request instead of looping if (ipanel()->RequestFocusPrev(_mainPanel->GetVParent(), _mainPanel->GetVPanel())) { bFound = true; SetCurrentDefaultButton(NULL); break; } } } // not found an item, loop back newPosition = 9999999; bRepeat = false; } if (best) { _currentFocus = best->GetVPanel(); best->RequestFocus(-1); bFound = true; if (!CanButtonBeDefault(best->GetVPanel())) { if (_defaultButton) { SetCurrentDefaultButton(_defaultButton); } else { SetCurrentDefaultButton(NULL); // we need to ask the parent to set its default button if (_mainPanel->GetVParent()) { ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), NULL); } } } else { SetCurrentDefaultButton(best->GetVPanel()); } } return bFound; }
//----------------------------------------------------------------------------- // Purpose: Re-aligns background image panels so they are touching. //----------------------------------------------------------------------------- static void FixupBackgroundPanels( EditablePanel *pWindow, int offsetX, int offsetY ) { if ( !pWindow ) return; int screenWide, screenTall; pWindow->GetSize( screenWide, screenTall ); int inset = GetAlternateProportionalValueFromNormal( 20 ); int cornerSize = GetAlternateProportionalValueFromNormal( 10 ); int titleHeight = GetAlternateProportionalValueFromNormal( 42 ); int mainHeight = GetAlternateProportionalValueFromNormal( 376 ); int logoSize = titleHeight; int captionInset = GetAlternateProportionalValueFromNormal( 76 ); Panel *pPanel; // corners -------------------------------------------- pPanel = pWindow->FindChildByName( "TopLeftPanel" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( offsetX + inset, offsetY + inset, cornerSize, cornerSize ); } pPanel = pWindow->FindChildByName( "TopRightPanel" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, offsetY + inset, cornerSize, cornerSize ); } pPanel = pWindow->FindChildByName( "BottomLeftPanel" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize ); } pPanel = pWindow->FindChildByName( "BottomRightPanel" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize ); } // background ----------------------------------------- pPanel = pWindow->FindChildByName( "TopSolid" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( offsetX + inset + cornerSize, offsetY + inset, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize ); } pPanel = pWindow->FindChildByName( "UpperMiddleSolid" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( offsetX + inset, offsetY + inset + cornerSize, screenWide - 2*offsetX - 2*inset, titleHeight ); } pPanel = pWindow->FindChildByName( "LowerMiddleSolid" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( offsetX + inset + cornerSize, screenTall - offsetY - inset - cornerSize, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize ); } pPanel = pWindow->FindChildByName( "BottomSolid" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize - mainHeight, screenWide - 2*offsetX - 2*inset, mainHeight ); } // transparent border --------------------------------- pPanel = pWindow->FindChildByName( "TopClear" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( 0, 0, screenWide, offsetY + inset ); } pPanel = pWindow->FindChildByName( "BottomClear" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( 0, screenTall - offsetY - inset, screenWide, offsetY + inset ); } pPanel = pWindow->FindChildByName( "LeftClear" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( 0, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset ); } pPanel = pWindow->FindChildByName( "RightClear" ); if ( pPanel ) { pPanel->SetZPos( -20 ); pPanel->SetBounds( screenWide - offsetX - inset, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset ); } // Logo ----------------------------------------------- int logoInset = (cornerSize + titleHeight - logoSize)/2; pPanel = pWindow->FindChildByName( "ExclamationPanel" ); if ( pPanel ) { pPanel->SetZPos( -19 ); // higher than the background pPanel->SetBounds( offsetX + inset + logoInset, offsetY + inset + logoInset, logoSize, logoSize ); } // Title caption -------------------------------------- pPanel = dynamic_cast< Label * >(pWindow->FindChildByName( "CaptionLabel" )); if ( pPanel ) { pPanel->SetZPos( -19 ); // higher than the background pPanel->SetBounds( offsetX + captionInset/*inset + 2*logoInset + logoSize*/, offsetY + inset + logoInset, screenWide, logoSize ); } }
const GuiObjectPtr Panel::GetChildAfter( GuiObjectCPtr _spChild ) const { Panel *pThis = const_cast< Panel* >( this ); return pThis->GetChildAfter( _spChild ); }
const ChildIterator Panel::GetChildIterator() const { Panel *pThis = const_cast< Panel* >( this ); return pThis->GetChildIterator(); }
int main() { int count = 0; int iterationCounter = 0; int countx = 1000; int middle = get_width()/2; setup_camera(); clock_t begin = 0; clock_t diff = 0; //margin is the radius around the middle of the field of vision //in which we will allow the robot to go straight while(true) { panel.SetRed(true); panel.SetGreen(false); chassis.Stop(); //wait for user to press start while(!panel.GetStart()) { usleep(10000); } turn_on_camera(); panel.SetGreen(true); panel.SetRed(false); /*//Go straight for a bit chassis.Drive(THROTTLE,0.0); usleep(5000000); chassis.Drive(0.0,0.0); usleep(3000000); //Go right for a bit chassis.Drive(THROTTLE,RIGHTTURN*1.0); usleep(2000000); chassis.Drive(0.0,0.0); usleep(3000000); //Go left for a bit chassis.Drive(THROTTLE,LEFTTURN*1.0); usleep(2000000); chassis.Drive(0.0,0.0); usleep(7000000); */ initialize(); int average = get_average(h,s,v, countx); float tFactor = 1.0; while(!panel.GetStop()) { //record timestamp to find elapsed time begin = clock(); int difference = average - middle; if (chassis.OnHill()) { cout<<"I'M ON A BOAT!!!!!!!!" <<endl; //tFactor = 0.5; tFactor = -.5; } else { cout<<"I'M LAME!!!!!!!!!"<<endl; tFactor= 1.0; } //tFactor = 1.0; if(abs(difference) > STEER_TOLERANCE) { chassis.Drive(THROTTLE * tFactor, STEER_SCALE * difference * 2 / (float) get_width()); } else { chassis.Drive(THROTTLE * tFactor, 0.0); } /* if (average < middle - margin) { //go right factor = abs(average - (middle - margin))/leftColumnWidth; chassis.Drive(THROTTLE,RIGHTTURN*factor); } else if (average > middle + margin) { //go left factor = abs(average - (middle + margin))/rightColumnWidth; chassis.Drive(THROTTLE,LEFTTURN*factor); } else { //go straight chassis.Drive(THROTTLE,0.0); } */ if(iterationCounter%picModNumber == 0) { //save images average = get_average(h,s,v,count); cout << average; cout << "-- " <<iterationCounter << "---" << count; cout << "---" << "Picture taken"; count++; } else { //don't save average = get_average(h,s,v,countx); cout << average; cout << "-- " <<iterationCounter << "---" << count; } diff = clock() - begin; cout << " --- " << (float) diff / (float) CLOCKS_PER_SEC << endl; usleep(5000); iterationCounter++; } count = 0; iterationCounter = 0; shut_down_camera(); } return 0; }
const GuiObjectPtr Panel::GetChild( Unsigned32 u32Idx ) const { Panel* pThis = const_cast< Panel* >( this ); return pThis->GetChild( u32Idx ); }
void CKeyBindingHelpDialog::PopulateList() { m_pList->DeleteAllItems(); int i, j; CUtlVector< ListInfo_t > maps; vgui2::Panel *pPanel = m_hPanel; while ( pPanel->IsKeyBindingChainToParentAllowed() ) { PanelKeyBindingMap *map = pPanel->GetKBMap(); while ( map ) { int k; int c = maps.Count(); for ( k = 0; k < c; ++k ) { if ( maps[k].m_pMap == map ) break; } if ( k == c ) { int mapIndex = maps.AddToTail( ); maps[mapIndex].m_pMap = map; maps[mapIndex].m_pPanel = pPanel; } map = map->baseMap; } pPanel = pPanel->GetParent(); if ( !pPanel ) break; } CUtlRBTree< KeyValues *, int > sorted( 0, 0, BindingLessFunc ); // add header item int c = maps.Count(); for ( i = 0; i < c; ++i ) { PanelKeyBindingMap *m = maps[ i ].m_pMap; Panel *pMapPanel = maps[i].m_pPanel; Assert( m ); int bindings = m->boundkeys.Count(); for ( j = 0; j < bindings; ++j ) { BoundKey_t *kbMap = &m->boundkeys[ j ]; Assert( kbMap ); // Create a new: blank item KeyValues *item = new KeyValues( "Item" ); // Fill in data char loc[ 128 ]; Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname ); char ansi[ 256 ]; AnsiText( loc, ansi, sizeof( ansi ) ); item->SetString( "Action", ansi ); item->SetWString( "Binding", Panel::KeyCodeModifiersToDisplayString( (KeyCode)kbMap->keycode, kbMap->modifiers ) ); // Find the binding KeyBindingMap_t *bindingMap = pMapPanel->LookupBinding( kbMap->bindingname ); if ( bindingMap && bindingMap->helpstring ) { AnsiText( bindingMap->helpstring, ansi, sizeof( ansi ) ); item->SetString( "Description", ansi ); } item->SetPtr( "Item", kbMap ); sorted.Insert( item ); } // Now try and find any "unbound" keys... int mappings = m->entries.Count(); for ( j = 0; j < mappings; ++j ) { KeyBindingMap_t *kbMap = &m->entries[ j ]; // See if it's bound CUtlVector< BoundKey_t * > list; pMapPanel->LookupBoundKeys( kbMap->bindingname, list ); if ( list.Count() > 0 ) continue; // Not bound, add a placeholder entry // Create a new: blank item KeyValues *item = new KeyValues( "Item" ); // fill in data char loc[ 128 ]; Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname ); char ansi[ 256 ]; AnsiText( loc, ansi, sizeof( ansi ) ); item->SetString( "Action", ansi ); item->SetWString( "Binding", L"" ); if ( kbMap->helpstring ) { AnsiText( kbMap->helpstring, ansi, sizeof( ansi ) ); item->SetString( "Description", ansi ); } item->SetPtr( "Unbound", kbMap ); sorted.Insert( item ); } } for ( j = sorted.FirstInorder() ; j != sorted.InvalidIndex(); j = sorted.NextInorder( j ) ) { KeyValues *item = sorted[ j ]; // Add to list m_pList->AddItem( item, 0, false, false ); item->deleteThis(); } sorted.RemoveAll(); }
ProjectManager::ProjectManager() { int margin = get_constant("margin","Dialogs"); int button_margin = get_constant("button_margin","Dialogs"); // load settings if (!EditorSettings::get_singleton()) EditorSettings::create(); set_area_as_parent_rect(); Panel *panel = memnew( Panel ); add_child(panel); panel->set_area_as_parent_rect(); VBoxContainer *vb = memnew( VBoxContainer ); panel->add_child(vb); vb->set_area_as_parent_rect(20); Label *l = memnew( Label ); l->set_text(_MKSTR(VERSION_NAME)" - Project Manager"); l->add_font_override("font",get_font("large","Fonts")); l->set_align(Label::ALIGN_CENTER); vb->add_child(l); l = memnew( Label ); l->set_text("v"VERSION_MKSTRING); //l->add_font_override("font",get_font("bold","Fonts")); l->set_align(Label::ALIGN_CENTER); vb->add_child(l); vb->add_child(memnew(HSeparator)); vb->add_margin_child("\n",memnew(Control)); HBoxContainer *tree_hb = memnew( HBoxContainer); vb->add_margin_child("Recent Projects:",tree_hb,true); PanelContainer *pc = memnew( PanelContainer); pc->add_style_override("panel",get_stylebox("bg","Tree")); tree_hb->add_child(pc); pc->set_h_size_flags(SIZE_EXPAND_FILL); scroll = memnew( ScrollContainer ); pc->add_child(scroll); scroll->set_enable_h_scroll(false); VBoxContainer *tree_vb = memnew( VBoxContainer); tree_hb->add_child(tree_vb); scroll_childs = memnew( VBoxContainer ); scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL); scroll->add_child(scroll_childs); //HBoxContainer *hb = memnew( HBoxContainer ); //vb->add_child(hb); Button *open = memnew( Button ); open->set_text("Edit"); tree_vb->add_child(open); open->connect("pressed", this,"_open_project"); open_btn=open; Button *run = memnew( Button ); run->set_text("Run"); tree_vb->add_child(run); run->connect("pressed", this,"_run_project"); run_btn=run; tree_vb->add_child(memnew( HSeparator )); Button *scan = memnew( Button ); scan->set_text("Scan"); tree_vb->add_child(scan); scan->connect("pressed", this,"_scan_projects"); tree_vb->add_child(memnew( HSeparator )); scan_dir = memnew( FileDialog ); scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM); scan_dir->set_mode(FileDialog::MODE_OPEN_DIR); add_child(scan_dir); scan_dir->connect("dir_selected",this,"_scan_begin"); Button* create = memnew( Button ); create->set_text("New Project"); tree_vb->add_child(create); create->connect("pressed", this,"_new_project"); Button* import = memnew( Button ); import->set_text("Import"); tree_vb->add_child(import); import->connect("pressed", this,"_import_project"); Button* erase = memnew( Button ); erase->set_text("Erase"); tree_vb->add_child(erase); erase->connect("pressed", this,"_erase_project"); erase_btn=erase; tree_vb->add_spacer(); Button * cancel = memnew( Button ); cancel->set_text("Exit"); tree_vb->add_child(cancel); cancel->connect("pressed", this,"_exit_dialog"); vb->add_margin_child("\n",memnew(Control)); vb->add_child(memnew(HSeparator)); l = memnew( Label ); String cp; cp.push_back(0xA9); cp.push_back(0); l->set_text(cp+" 2008-2012 Juan Linietsky, Ariel Manzur."); l->set_align(Label::ALIGN_CENTER); vb->add_child(l); erase_ask = memnew( ConfirmationDialog ); erase_ask->get_ok()->set_text("Erase"); erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm"); add_child(erase_ask); multi_open_ask = memnew( ConfirmationDialog ); multi_open_ask->get_ok()->set_text("Edit"); multi_open_ask->get_ok()->connect("pressed", this, "_open_project_confirm"); add_child(multi_open_ask); multi_run_ask = memnew( ConfirmationDialog ); multi_run_ask->get_ok()->set_text("Run"); multi_run_ask->get_ok()->connect("pressed", this, "_run_project_confirm"); add_child(multi_run_ask); OS::get_singleton()->set_low_processor_usage_mode(true); npdialog = memnew( NewProjectDialog ); add_child(npdialog); Ref<Theme> theme = memnew( Theme ); editor_register_icons(theme); set_theme(theme); npdialog->connect("project_created", this,"_load_recent_projects"); _load_recent_projects(); //get_ok()->set_text("Open"); //get_ok()->set_text("Exit"); last_clicked = ""; }
bool Workarea::handleEvent(const SDL_Event & event) { gcn::FocusHandler *fh = m_gui->getFocusHandler(); assert(fh != 0); gcn::Widget *focus = fh->getFocused(); bool clear_focus = false; bool event_eaten = false; bool suppress = false; Panel *panel = dynamic_cast<Panel*>(m_panel); switch (event.type) { case SDL_MOUSEMOTION: // FIXME This should depend on whether the gui is visible. event_eaten = m_gui->getWidgetAt(event.motion.x, event.motion.y) != m_top; break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: // FIXME This should depend on whether the gui is visible. event_eaten = m_gui->getWidgetAt(event.button.x, event.button.y) != m_top; break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_RETURN) { if (panel != 0 && System::instance()->checkState(SYS_IN_WORLD) && (focus == 0 || focus == m_top)) { suppress = panel->requestConsole(); } event_eaten = true; } else if (event.key.keysym.sym == SDLK_SLASH) { if (panel != 0 && System::instance()->checkState(SYS_IN_WORLD) && (focus == 0 || focus == m_top)) { panel->requestConsole(); } event_eaten = true; } else if (event.key.keysym.sym == SDLK_ESCAPE) { if (panel != 0) { suppress = panel->dismissConsole(); } event_eaten = true; } else { event_eaten = ((focus != 0) && (focus != m_top)); } case SDL_KEYUP: event_eaten = ((focus != 0) && (focus != m_top)); break; default: event_eaten = false; break; } if (!suppress) { m_input->pushInput(event); } if (clear_focus) { fh->focusNone(); } focus = fh->getFocused(); if ((focus != 0) && (focus != m_top)) { if (m_system->isMouselookEnabled()) { m_system->toggleMouselook(); } } return event_eaten; }
void Shader::OnCommand(wxCommandEvent& evt) { Project *project = Project::GetProject(); Panel *panel; Undoer *undoer; Graph *graph; if (project != NULL) { panel = project->GetPanel(); if (panel != NULL) { undoer = panel->GetUndoerCtrl(); graph = panel->GetGraphCtrl(); } } switch (evt.GetId()) { case wxID_OPEN: Open(); break; case wxID_SAVE: Save(); break; case wxID_SAVEAS: SaveAs(); break; case wxID_EXIT: Close(false); break; case wxID_UNDO: undoer->Undo(); break; case wxID_REDO: undoer->Redo(); break; case wxID_CUT: graph->Cut(); break; case wxID_COPY: graph->Copy(); break; case wxID_PASTE: graph->Paste(); break; case wxID_DUPLICATE: graph->Duplicate(); break; case wxID_GROUP: graph->GroupNodes(); break; case wxID_UNGROUP: graph->UngroupNodes(); break; case wxID_SAVEGROUP: graph->SaveGroup(); break; case wxID_COPYMETAFILE: graph->CopyAsMetafile(); break; case wxID_CONFIGURE: project->Configure(); break; case wxID_RELOADLIBS: //project->ReloadLibs(); break; } }
EditorFontImportDialog(EditorFontImportPlugin *p_plugin) { plugin=p_plugin; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); HBoxContainer *hbc = memnew( HBoxContainer); vbc->add_child(hbc); VBoxContainer *vbl = memnew( VBoxContainer ); hbc->add_child(vbl); hbc->set_v_size_flags(SIZE_EXPAND_FILL); vbl->set_h_size_flags(SIZE_EXPAND_FILL); VBoxContainer *vbr = memnew( VBoxContainer ); hbc->add_child(vbr); vbr->set_h_size_flags(SIZE_EXPAND_FILL); source = memnew( LineEditFileChooser ); source->get_file_dialog()->set_access(FileDialog::ACCESS_FILESYSTEM); source->get_file_dialog()->set_mode(FileDialog::MODE_OPEN_FILE); source->get_file_dialog()->add_filter("*.ttf;TrueType"); source->get_file_dialog()->add_filter("*.otf;OpenType"); source->get_line_edit()->connect("text_entered",this,"_src_changed"); vbl->add_margin_child("Source Font:",source); font_size = memnew( SpinBox ); vbl->add_margin_child("Source Font Size:",font_size); font_size->set_min(3); font_size->set_max(256); font_size->set_val(16); font_size->connect("value_changed",this,"_font_size_changed"); dest = memnew( LineEditFileChooser ); // List<String> fl; Ref<Font> font= memnew(Font); dest->get_file_dialog()->add_filter("*.fnt ; Font" ); //ResourceSaver::get_recognized_extensions(font,&fl); //for(List<String>::Element *E=fl.front();E;E=E->next()) { // dest->get_file_dialog()->add_filter("*."+E->get()); //} vbl->add_margin_child("Dest Resource:",dest); HBoxContainer *testhb = memnew( HBoxContainer ); test_string = memnew( LineEdit ); test_string->set_text("The quick brown fox jumps over the lazy dog."); test_string->set_h_size_flags(SIZE_EXPAND_FILL); test_string->set_stretch_ratio(5); testhb->add_child(test_string); test_color = memnew( ColorPickerButton ); test_color->set_color(get_color("font_color","Label")); test_color->set_h_size_flags(SIZE_EXPAND_FILL); test_color->set_stretch_ratio(1); test_color->connect("color_changed",this,"_update_text3"); testhb->add_child(test_color); vbl->add_spacer(); vbl->add_margin_child("Test: ",testhb); HBoxContainer *upd_hb = memnew( HBoxContainer ); // vbl->add_child(upd_hb); upd_hb->add_spacer(); Button *update = memnew( Button); upd_hb->add_child(update); update->set_text("Update"); update->connect("pressed",this,"_update"); options = memnew( _EditorFontImportOptions ); prop_edit = memnew( PropertyEditor() ); vbr->add_margin_child("Options:",prop_edit,true); options->connect("changed",this,"_prop_changed"); prop_edit->hide_top_label(); Panel *panel = memnew( Panel ); vbc->add_child(panel); test_label = memnew( Label ); test_label->set_autowrap(true); panel->add_child(test_label); test_label->set_area_as_parent_rect(); panel->set_v_size_flags(SIZE_EXPAND_FILL); test_string->connect("text_changed",this,"_update_text2"); set_title("Font Import"); timer = memnew( Timer ); add_child(timer); timer->connect("timeout",this,"_update"); timer->set_wait_time(0.4); timer->set_one_shot(true); get_ok()->connect("pressed", this,"_import"); get_ok()->set_text("Import"); error_dialog = memnew ( ConfirmationDialog ); add_child(error_dialog); error_dialog->get_ok()->set_text("Accept"); set_hide_on_ok(false); }
//----------------------------------------------------------------------------- // Purpose: Sets the focus to the previous panel in the tab order // Input : *panel - panel currently with focus //----------------------------------------------------------------------------- bool FocusNavGroup::RequestFocusNext(VPANEL panel) { // basic recursion guard, in case user has set up a bad focus hierarchy static int stack_depth = 0; stack_depth++; _currentFocus = NULL; int newPosition = 0; if (panel) { newPosition = ipanel()->GetTabPosition(panel); } bool bFound = false; bool bRepeat = true; Panel *best = NULL; while (1) { newPosition++; int bestPosition = 999999; // look for the next tab position for (int i = 0; i < _mainPanel->GetChildCount(); i++) { Panel *child = _mainPanel->GetChild(i); if ( !child ) continue; if (child && child->IsVisible() && child->IsEnabled() && child->GetTabPosition()) { int tabPosition = child->GetTabPosition(); if (tabPosition == newPosition) { // we've found the right tab best = child; bestPosition = newPosition; // don't loop anymore since we've found the correct panel break; } else if (tabPosition > newPosition && tabPosition < bestPosition) { // record the match since this is the closest so far bestPosition = tabPosition; best = child; } } } if (!bRepeat) break; if (best) break; // haven't found an item // check to see if we should push the focus request up if (!_topLevelFocus) { if (_mainPanel->GetVParent() && _mainPanel->GetVParent() != surface()->GetEmbeddedPanel()) { // we're not a top level panel, so forward up the request instead of looping if (stack_depth < 15) { if (ipanel()->RequestFocusNext(_mainPanel->GetVParent(), _mainPanel->GetVPanel())) { bFound = true; SetCurrentDefaultButton(NULL); break; } // if we find one then we break, otherwise we loop } } } // loop back newPosition = 0; bRepeat = false; } if (best) { _currentFocus = best->GetVPanel(); best->RequestFocus(1); bFound = true; if (!CanButtonBeDefault(best->GetVPanel())) { if (_defaultButton) { SetCurrentDefaultButton(_defaultButton); } else { SetCurrentDefaultButton(NULL); // we need to ask the parent to set its default button if (_mainPanel->GetVParent()) { ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), NULL); } } } else { SetCurrentDefaultButton(best->GetVPanel()); } } stack_depth--; return bFound; }
virtual void init() { SceneMainLoop::init(); #if 0 Viewport *vp = memnew( Viewport ); vp->set_world( Ref<World>( memnew( World ))); get_root()->add_child(vp); vp->set_rect(Rect2(0,0,256,256)); vp->set_as_render_target(true); vp->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS); Camera *camera = memnew( Camera ); vp->add_child(camera); camera->make_current(); TestCube *testcube = memnew( TestCube ); vp->add_child(testcube); testcube->set_transform(Transform( Matrix3().rotated(Vector3(0,1,0),Math_PI*0.25), Vector3(0,0,-8))); Sprite *sp = memnew( Sprite ); sp->set_texture( vp->get_render_target_texture() ); // sp->set_texture( ResourceLoader::load("res://ball.png") ); sp->set_pos(Point2(300,300)); get_root()->add_child(sp); return; #endif Panel * frame = memnew( Panel ); frame->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END ); frame->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END ); frame->set_end( Point2(0,0) ); get_root()->add_child( frame ); Label *label = memnew( Label ); label->set_pos( Point2( 80,90 ) ); label->set_size( Point2( 170,80 ) ); label->set_align( Label::ALIGN_FILL ); //label->set_text("There"); label->set_text("There was once upon a time a beautiful unicorn that loved to play with little girls..."); frame->add_child(label); Button *button = memnew( Button ); button->set_pos( Point2( 20,20 ) ); button->set_size( Point2( 1,1 ) ); button->set_text("This is a biggie button"); frame->add_child( button ); #if 0 Sprite *tf = memnew( Sprite ); frame->add_child(tf); Image img; ImageLoader::load_image("LarvoClub.png",&img); img.resize(512,512); img.generate_mipmaps(); img.compress(); Ref<Texture> text = memnew( Texture ); text->create_from_image(img); tf->set_texture(text); tf->set_pos(Point2(50,50)); //tf->set_scale(Point2(0.3,0.3)); return; #endif Tree * tree = memnew( Tree ); tree->set_columns(2); tree->set_pos( Point2( 230,210 ) ); tree->set_size( Point2( 150,250 ) ); TreeItem *item = tree->create_item(); item->set_editable(0,true); item->set_text(0,"root"); item = tree->create_item( tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); item->set_editable(0,true); item->set_text(0,"check"); item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK); item->set_editable(1,true); item->set_text(1,"check2"); item = tree->create_item( tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); item->set_editable(0,true); item->set_range_config(0,0,20,0.1); item->set_range(0,2); item->add_button(0,Theme::get_default()->get_icon("folder","FileDialog")); item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); item->set_editable(1,true); item->set_range_config(1,0,20,0.1); item->set_range(1,3); item = tree->create_item( tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); item->set_editable(0,true); item->set_text(0,"Have,Many,Several,Options!"); item->set_range(0,2); item = tree->create_item( item ); item->set_editable(0,true); item->set_text(0,"Gershwin!"); frame->add_child(tree); //control = memnew( Control ); //root->add_child( control ); LineEdit *line_edit = memnew( LineEdit ); line_edit->set_pos( Point2( 30,190 ) ); line_edit->set_size( Point2( 180,1 ) ); frame->add_child(line_edit); HScrollBar *hscroll = memnew( HScrollBar ); hscroll->set_pos( Point2( 30,290 ) ); hscroll->set_size( Point2( 180,1 ) ); hscroll->set_max(10); hscroll->set_page(4); frame->add_child(hscroll); SpinBox *spin = memnew( SpinBox ); spin->set_pos( Point2( 30,260 ) ); spin->set_size( Point2( 120,1 ) ); frame->add_child(spin); hscroll->share(spin); ProgressBar *progress = memnew( ProgressBar ); progress->set_pos( Point2( 30,330 ) ); progress->set_size( Point2( 120,1 ) ); frame->add_child(progress); hscroll->share(progress); MenuButton *menu_button = memnew( MenuButton ); menu_button->set_text("I'm a menu!"); menu_button->set_pos( Point2( 30,380 ) ); menu_button->set_size( Point2( 1,1 ) ); frame->add_child(menu_button); PopupMenu *popup = menu_button->get_popup(); popup->add_item("Hello, testing"); popup->add_item("My Dearest"); popup->add_separator(); popup->add_item("Popup"); popup->add_check_item("Check Popup"); popup->set_item_checked(4,true); OptionButton *options = memnew( OptionButton ); options->add_item("Hello, testing"); options->add_item("My Dearest"); options->set_pos( Point2( 230,180 ) ); options->set_size( Point2( 1,1 ) ); frame->add_child(options); /* Tree * tree = memnew( Tree ); tree->set_columns(2); tree->set_pos( Point2( 230,210 ) ); tree->set_size( Point2( 150,250 ) ); TreeItem *item = tree->create_item(); item->set_editable(0,true); item->set_text(0,"root"); item = tree->create_item( tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); item->set_editable(0,true); item->set_text(0,"check"); item = tree->create_item( tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); item->set_editable(0,true); item->set_range_config(0,0,20,0.1); item->set_range(0,2); item->add_button(0,Theme::get_default()->get_icon("folder","FileDialog")); item = tree->create_item( tree->get_root() ); item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); item->set_editable(0,true); item->set_text(0,"Have,Many,Several,Options!"); item->set_range(0,2); frame->add_child(tree); */ RichTextLabel *richtext = memnew( RichTextLabel ); richtext->set_pos( Point2( 600,210 ) ); richtext->set_size( Point2( 180,250 ) ); richtext->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,20); frame->add_child(richtext); richtext->add_text("Hello, My Friends!\n\nWelcome to the amazing world of "); richtext->add_newline(); richtext->add_newline(); richtext->push_color(Color(1,0.5,0.5)); richtext->add_text("leprechauns"); richtext->pop(); #if 0 richtext->add_text(" and "); richtext->push_color(Color(0,1.0,0.5)); richtext->add_text("faeries.\n"); richtext->pop(); richtext->add_text("In this new episode, we will attemp to "); richtext->push_font(richtext->get_font("mono_font","Fonts")); richtext->push_color(Color(0.7,0.5,1.0)); richtext->add_text("deliver something nice"); richtext->pop(); richtext->pop(); richtext->add_text(" to all the viewers! Unfortunately, I need to "); richtext->push_underline(); richtext->add_text("keep writing a lot of text"); richtext->pop(); richtext->add_text(" so the label control overflows and the scrollbar appears.\n"); //richtext->push_indent(1); //richtext->add_text("By the way, testing indent levels! Yohohoho! Everything should appear to the right sightly here!\n"); //richtext->pop(); richtext->push_meta("http://www.scrollingcapabilities.xz"); richtext->add_text("This allows to test for the scrolling capabilities "); richtext->pop(); richtext->add_text("of the rich text label for huge text (not like this text will really be huge but, you know).\nAs long as it is so long that it will work nicely for a test/demo, then it's welcomed in my book...\nChanging subject, the day is cloudy today and I'm wondering if I'll get che chance to travel somewhere nice. Sometimes, watching the clouds from satellite images may give a nice insight about how pressure zones in our planet work, althogh it also makes it pretty obvious to see why most weather forecasts get it wrong so often.\nClouds are so difficult to predict!\nBut it's pretty cool how our civilization has adapted to having water falling from the sky each time it rains..."); //richtext->add_text("Hello!\nGorgeous.."); #endif //richtext->push_meta("http://www.scrollingcapabilities.xz"); ///richtext->add_text("Hello!\n"); //richtext->pop(); richtext->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); TabContainer * tabc = memnew( TabContainer ); Control *ctl= memnew( Control ); ctl->set_name("tab 1"); tabc->add_child(ctl); ctl= memnew( Control ); ctl->set_name("tab 2"); tabc->add_child(ctl); label = memnew( Label ); label->set_text("Some Label"); label->set_pos( Point2(20,20) ); ctl->add_child(label);; ctl= memnew( Control ); ctl->set_name("tab 3"); button = memnew( Button ); button->set_text("Some Button"); button->set_pos( Point2(30,50) ); ctl->add_child(button);; tabc->add_child(ctl); frame->add_child(tabc); tabc->set_pos( Point2( 400,210 ) ); tabc->set_size( Point2( 180,250 ) ); Ref<ImageTexture> text = memnew( ImageTexture ); text->load("test_data/concave.png"); Sprite* sprite = memnew(Sprite); sprite->set_texture(text); sprite->set_pos(Point2(300, 300)); frame->add_child(sprite); sprite->show(); Sprite* sprite2 = memnew(Sprite); sprite->set_texture(text); sprite->add_child(sprite2); sprite2->set_pos(Point2(50, 50)); sprite2->show(); }
MenuSelection::MenuSelection() : Panel() { Panel* selection_top = new Panel(1200, 200); this->add(selection_top, (Alignment::TOP | Alignment::LEFT)); selection_top->setBgColor(Color::WHITE); selection_top->setBackground((*ServiceLocator::getTextureManager())["menuSelectTopBG"]); Label* j1 = new Label(150, 50, "Joueur 1 :", (*ServiceLocator::getFontManager())["LifeCraft"]); selection_top->add(j1); j1->setPositionX(100); j1->setPositionY(50); Label* j2 = new Label(150, 50, "Joueur 2 :", (*ServiceLocator::getFontManager())["LifeCraft"]); selection_top->add(j2); j2->setPositionX(1000); j2->setPositionY(50); choiceJ1 = new Button(75, 75); selection_top->add(choiceJ1); choiceJ1->setHover(false); choiceJ1->setPosition(110, 100); /*Texture t = (*ServiceLocator::getTextureManager())["obstacle_0"]; choiceJ1->setBackground(t); choiceJ1->setHoverBackground(t);*/ nameJ1 = new Label(150, 50, "J1", (*ServiceLocator::getFontManager())["LifeCraft"]); selection_top->add(nameJ1); nameJ1->setPositionX(325); nameJ1->setPositionY(110); choiceJ2 = new Button(75, 75); selection_top->add(choiceJ2); choiceJ2->setHover(false); choiceJ2->setPosition(1015, 100); /*Texture t2 = (*ServiceLocator::getTextureManager())["obstacle_1"]; choiceJ2->setBackground(t2); choiceJ2->setHoverBackground(t2);*/ nameJ2 = new Label(150, 50, "J2", (*ServiceLocator::getFontManager())["LifeCraft"]); selection_top->add(nameJ2); nameJ2->setPositionX(800); nameJ2->setPositionY(110); button_selec_1 = new Button(150, 50); selection_top->add(button_selec_1); button_selec_1->setText("Pret"); button_selec_1->setTextAlignment(Alignment::CENTERX | Alignment::CENTERY); button_selec_1->setPositionY(100); button_selec_1->setPositionX(525); button_selec_1->setBackground((*ServiceLocator::getTextureManager())["BackgroundReady"]); button_selec_1->setHoverBackground((*ServiceLocator::getTextureManager())["BackgroundReadyHover"]); //button_selec_1->setBgColor(Color::RED); button_selec_1->Clickable::setCallback(new EventCallback([=](Event*) {ready(); })); Panel* selection_bottom = new Panel(1200, 700); this->add(selection_bottom); Texture selBottom = (*ServiceLocator::getTextureManager())["menuSelectBG"]; selection_bottom->setBackground(selBottom); selection_bottom->setBgColor(Color::BLUE); selection_bottom->setPosition(0, 200); Button* flecheLeft = new Button(50, 50); selection_bottom->add(flecheLeft); flecheLeft->setPosition(20, 270); flecheLeft->Clickable::setCallback(new EventCallback([=](Event*) {clickArrow('l'); })); flecheLeft->setHoverBackground((*ServiceLocator::getTextureManager())["flecheG"]); flecheLeft->setBackground((*ServiceLocator::getTextureManager())["flecheG"]); Button* flecheRight = flecheLeft->clone(); selection_bottom->add(flecheRight); flecheRight->setPosition(500, 270); flecheRight->Clickable::setCallback(new EventCallback([=](Event*) {clickArrow('r'); })); flecheRight->setHoverBackground((*ServiceLocator::getTextureManager())["flecheD"]); flecheRight->setBackground((*ServiceLocator::getTextureManager())["flecheD"]); showSelectChar = new Button(300, 300); selection_bottom->add(showSelectChar); showSelectChar->setPosition(150, 200); //showSelectChar->setHover(false); //showSelectChar->Clickable::setCallback(new EventCallback([=](Event*) {selectClass(a); })); showSelectChar->setHoverBackground((*ServiceLocator::getTextureManager())["icon_archer"]); showSelectChar->setBackground((*ServiceLocator::getTextureManager())["icon_archer"]); /* Button* choice1 = new Button(125, 125); selection_bottom->add(choice1); choice1->setPosition(200, 100); choice1->Clickable::setCallback(new EventCallback([=](Event*) {selectClass(a); })); choice1->setHoverBackground((*ServiceLocator::getTextureManager())["icon_archer"]); choice1->setBackground((*ServiceLocator::getTextureManager())["icon_archer"]); Button* choice2 = choice1->clone(); selection_bottom->add(choice2); choice2->setPosition(200 - 62, 100 + 125); choice2->Clickable::setCallback(new EventCallback([=](Event*) {selectClass(k); })); choice2->setBackground((*ServiceLocator::getTextureManager())["icon_knight"]); choice2->setHoverBackground((*ServiceLocator::getTextureManager())["icon_knight"]); Button* choice3 = choice1->clone(); selection_bottom->add(choice3); choice3->setPosition(200 + 63, 100 + 125); choice3->Clickable::setCallback(new EventCallback([=](Event*) {selectClass(m); })); choice3->setBackground((*ServiceLocator::getTextureManager())["icon_mage"]); choice3->setHoverBackground((*ServiceLocator::getTextureManager())["icon_mage"]);*/ Panel* spellInfos = new Panel(500, 500); this->add(spellInfos); spellInfos->setBackground((*ServiceLocator::getTextureManager())["parchemin"]); int daX = 30; //décalage en X pour les labels (test de background texture) int daY = 30;//décalage en Y pour les labels (test de background texture) spellInfos->setPosition(600, 250); nomClasse = new Label(150, 25, "Nom Classe", (*ServiceLocator::getFontManager())["LifeCraft"]); spellInfos->add(nomClasse); nomClasse->setPosition(25 + daX, 10 + daY); descrClasse = new Label(400, 35, "Description de la classe : bla bla bla bla bla bla bla", (*ServiceLocator::getFontManager())["LifeCraft"]); //spellInfos->add(descrClasse); descrClasse->setPosition(15 + daX, 35 + daY); descrClasse->setTextSize(22); spell1 = new Button(75, 75); spellInfos->add(spell1); spell1->setPosition(50 + daX, 100 + daY); spell1->Clickable::setCallback(new EventCallback([=](Event*) {selectSpell(0); })); spell2 = new Button(75, 75); spellInfos->add(spell2); spell2->setPosition(50 + 100 + daX, 100 + daY); spell2->Clickable::setCallback(new EventCallback([=](Event*) {selectSpell(1); })); spell3 = new Button(75, 75); spellInfos->add(spell3); spell3->setPosition(50 + 100 + 100 + daX, 100 + daY); spell3->Clickable::setCallback(new EventCallback([=](Event*) {selectSpell(2); })); spell4 = new Button(75, 75); spellInfos->add(spell4); spell4->setPosition(50 + 100 + 100 + 100 + daX, 100 + daY); spell4->Clickable::setCallback(new EventCallback([=](Event*) {selectSpell(3); })); nomSpell = new Label(400, 50, "Nom Spell", (*ServiceLocator::getFontManager())["LifeCraft"]); spellInfos->add(nomSpell); nomSpell->setPosition(25 + daX, 175 + daY); descrSpell = new Label(500, 150, "Description du Spell : bla bla bla bla bla", (*ServiceLocator::getFontManager())["LifeCraft"]); spellInfos->add(descrSpell); descrSpell->setPosition(25 + daX, 205 + daY); descrSpell->setTextSize(22); descrSpell->setTextAlignment(Alignment::CENTERY | Alignment::LEFT); infos = new Label(400, 35, "Cost : X , Range : Y , inline / aoe", (*ServiceLocator::getFontManager())["LifeCraft"]); spellInfos->add(infos); infos->setPosition(25 + daX, 350 + daY); infos->setTextSize(22); unsigned int n = rand() % Grid::CELLS_NUMBER; while (GAMEINST->getGrid()->getCell(n)->getType() != Cell::Free) { n = rand() % Grid::CELLS_NUMBER; } a = new Archer(GAMEINST->getGrid()->getCell(n)->getPosX(), GAMEINST->getGrid()->getCell(n)->getPosY()); while (GAMEINST->getGrid()->getCell(n)->getType() != Cell::Free) { n = rand() % Grid::CELLS_NUMBER; } k = new Knight(GAMEINST->getGrid()->getCell(n)->getPosX(), GAMEINST->getGrid()->getCell(n)->getPosY()); while (GAMEINST->getGrid()->getCell(n)->getType() != Cell::Free) { n = rand() % Grid::CELLS_NUMBER; } m = new Mage(GAMEINST->getGrid()->getCell(n)->getPosX(), GAMEINST->getGrid()->getCell(n)->getPosY()); selectClass(a); }
//============================================================================= void InGameChapterSelect::OnCommand(const char *command) { if ( const char* szMissionItem = StringAfterPrefix( command, "cmd_campaign_" ) ) { if ( !Q_stricmp( szMissionItem, m_chCampaign ) ) return; // Setting to same mission Q_strncpy( m_chCampaign, szMissionItem, ARRAYSIZE( m_chCampaign ) ); // Determine current game settings KeyValues *pGameSettings = g_pMatchFramework->GetMatchNetworkMsgController()->GetActiveServerGameDetails( NULL ); KeyValues::AutoDelete autodelete_pGameSettings( pGameSettings ); if ( !pGameSettings ) return; DropDownMenu *pMissionDropDown = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpMission" ) ); if( pMissionDropDown ) //we should become a listener for events pertaining to the mission flyout { FlyoutMenu* missionFlyout = pMissionDropDown->GetCurrentFlyout(); if( missionFlyout ) { missionFlyout->SetListener( this ); if ( vgui::Button *pAddonBtn = missionFlyout->FindChildButtonByCommand( "cmd_addoncampaign" ) ) { pAddonBtn->SetEnabled( false ); } // Disable all other campaigns that cannot be used for a vote for ( int k = 0, kNum = missionFlyout->GetChildCount(); k < kNum; ++ k ) { Panel *child = missionFlyout->GetChild( k ); if ( BaseModHybridButton* button = dynamic_cast< BaseModHybridButton* >( child ) ) { if ( const char* commandValue = button->GetCommand()->GetString( "command", NULL ) ) { if ( char const *szMissionName = StringAfterPrefix( commandValue, "cmd_campaign_" ) ) { pGameSettings->SetString( "game/campaign", szMissionName ); pGameSettings->SetInt( "game/chapter", 1 ); if ( !g_pMatchExtSwarm->GetMapInfo( pGameSettings ) ) { button->SetEnabled( false ); } } } } } } } } else if ( char const *szChapterSelected = StringAfterPrefix( command, "#L4D360UI_Chapter_" ) ) { m_nChapter = atoi( szChapterSelected ); UpdateChapterImage( m_chCampaign, m_nChapter ); } else if ( !Q_stricmp( command, "Select" ) ) { KeyValues *pGameSettings = g_pMatchFramework->GetMatchNetworkMsgController()->GetActiveServerGameDetails( NULL ); KeyValues::AutoDelete autodelete_pGameSettings( pGameSettings ); if ( !GameModeIsSingleChapter( pGameSettings->GetString( "game/mode" ) ) ) m_nChapter = 1; pGameSettings->SetString( "game/campaign", m_chCampaign ); pGameSettings->SetInt( "game/chapter", m_nChapter ); char const *szVoteCommand = "ChangeChapter"; int iUser = GetGameUIActiveSplitScreenPlayerSlot(); GAMEUI_ACTIVE_SPLITSCREEN_PLAYER_GUARD( iUser ); Panel *pDrpChapter = FindChildByName( "DrpChapter" ); if ( !pDrpChapter || !pDrpChapter->IsEnabled() ) { szVoteCommand = "ChangeMission"; m_nChapter = 1; engine->ClientCmd( CFmtStr( "callvote %s %s;", szVoteCommand, m_chCampaign ) ); } else if ( KeyValues *pInfoMap = g_pMatchExtSwarm->GetMapInfo( pGameSettings ) ) { engine->ClientCmd( CFmtStr( "callvote %s %s;", szVoteCommand, pInfoMap->GetString( "map" ) ) ); } GameUI().AllowEngineHideGameUI(); engine->ClientCmd( "gameui_hide" ); Close(); } else if ( !Q_strcmp( command, "Cancel" ) ) { GameUI().AllowEngineHideGameUI(); engine->ClientCmd("gameui_hide"); Close(); } }
void ResizeWindowControls( EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY ) { if (!pWindow || !pWindow->GetBuildGroup() || !pWindow->GetBuildGroup()->GetPanelList()) return; CUtlVector<PHandle> *panelList = pWindow->GetBuildGroup()->GetPanelList(); CUtlVector<Panel *> resizedPanels; CUtlVector<Panel *> movedPanels; // Resize to account for 1.25 aspect ratio (1280x1024) screens { for ( int i = 0; i < panelList->Size(); ++i ) { PHandle handle = (*panelList)[i]; Panel *panel = handle.Get(); bool found = false; for ( int j = 0; j < resizedPanels.Size(); ++j ) { if (panel == resizedPanels[j]) found = true; } if (!panel || found) { continue; } resizedPanels.AddToTail( panel ); // don't move a panel more than once if ( panel != pWindow ) { RepositionControl( panel ); } } } // and now re-center them. Woohoo! for ( int i = 0; i < panelList->Size(); ++i ) { PHandle handle = (*panelList)[i]; Panel *panel = handle.Get(); bool found = false; for ( int j = 0; j < movedPanels.Size(); ++j ) { if (panel == movedPanels[j]) found = true; } if (!panel || found) { continue; } movedPanels.AddToTail( panel ); // don't move a panel more than once if ( panel != pWindow ) { int x, y; panel->GetPos( x, y ); panel->SetPos( x + offsetX, y + offsetY ); #if DEBUG_WINDOW_REPOSITIONING DevMsg( "Repositioning '%s' from (%d,%d) to (%d,%d) -- a distance of (%d,%d)\n", panel->GetName(), x, y, x + offsetX, y + offsetY, offsetX, offsetY ); #endif } } }
CCode_Editor::CCode_Editor( CSheet_Base *parent, const char *pName, CSmartText::CodeEditMode_t mode ) : BaseClass( parent, pName ) { m_iMode = mode; Activate(); SetVisible( true ); SetPaintBackgroundEnabled(true); SetPaintEnabled(true); SetSizeable(true); SetMoveable(true); SetMinimumSize( 500, 400 ); SetDeleteSelfOnClose( true ); m_iLastAppliedCodeIndex = 0; m_pCodeWindow = new CSmartText( this, "codewindow", mode ); m_pCodeWindow->AddActionSignalTarget( this ); /* TextEntry *pT = new TextEntry( this, "codewindow" ); pT->SetMultiline( true ); pT->SetEditable( true ); pT->SetCatchEnterKey( true ); pT->SetVerticalScrollbar( true ); */ LoadControlSettings( "shadereditorui/vgui/code_editor_Window.res" ); UpdateButtonEnabled( true, true ); SetCloseButtonVisible(false); int w,t; surface()->GetScreenSize( w, t ); w *= 0.75f; t *= 0.75f; SetSize( max( w, 500 ), max( t, 400 ) ); //SetKeyBoardInputEnabled( false ); //SetMouseInputEnabled( true ); //SetTitle( "Editor", true ); SetTitle( "", false ); Panel *pButton = FindChildByName( "button_save" ); if ( pButton ) pButton->SetKeyBoardInputEnabled( false ); pButton = FindChildByName( "button_apply" ); if ( pButton ) pButton->SetKeyBoardInputEnabled( false ); pButton = FindChildByName( "button_cancel" ); if ( pButton ) pButton->SetKeyBoardInputEnabled( false ); DoModal(); int rx, ry, rsx, rsy; if ( pEditorRoot->GetCodeEditorBounds( rx, ry, rsx, rsy ) ) SetBounds( rx, ry, rsx, rsy ); else MoveToCenterOfScreen(); }
void elevator::press(int n) { buttons.press(n); }
LetterW::LetterW(CRGB ledPanel[6][256], Panel connection) { _red = 0; _green = 0; _blue = 20; _row = 0; _col = 0; // Set points for letter _shapeArray[0][0] = 0; _shapeArray[0][1] = 0; _shapeArray[1][0] = 0; _shapeArray[1][1] = 1; _shapeArray[2][0] = 0; _shapeArray[2][1] = 2; _shapeArray[3][0] = 0; _shapeArray[3][1] = 3; _shapeArray[4][0] = 0; _shapeArray[4][1] = 4; _shapeArray[5][0] = 1; _shapeArray[5][1] = 3; _shapeArray[6][0] = 2; _shapeArray[6][1] = 2; _shapeArray[7][0] = 3; _shapeArray[7][1] = 3; _shapeArray[8][0] = 4; _shapeArray[8][1] = 0; _shapeArray[9][0] = 4; _shapeArray[9][1] = 1; _shapeArray[10][0] = 4; _shapeArray[10][1] = 2; _shapeArray[11][0] = 4; _shapeArray[11][1] = 3; _shapeArray[12][0] = 4; _shapeArray[12][1] = 4; // Turn on LED's int i=0; int x; int y; while(_shapeArray[i][0] >= 0){ x = _shapeArray[i][0]; y = _shapeArray[i][1]; connection.ledOn(x, y, ledPanel); i += 1; } FastLED.show(); }
int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_VIDEO); displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 360, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(displayWindow); SDL_GL_MakeCurrent(displayWindow, context); #ifdef _WINDOWS glewInit(); #endif glViewport(0, 0, 640, 360); ShaderProgram program(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl"); Matrix projectionMatrix; Matrix modelMatrix; Matrix viewMatrix; Matrix panelOneMatrix; Matrix panelTwoMatrix; projectionMatrix.setOrthoProjection(-3.55f, 3.55f, -2.0f, 2.0f, -1.0f, 1.0f); GLuint textureID = LoadTexture("ball.png"); GLuint panelTexID = LoadTexture("red_panel.png"); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Ball *ball = new Ball(0.0f, 0.0f, 3.0f, 3.0f, 0.2f); Panel *panelOne = new Panel(-3.55f, ball); Panel *panelTwo = new Panel(3.55f, ball); float lastFrameTicks = 0.0f; float angle = 0.0f; SDL_Event event; bool done = false; while (!done) { while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) { done = true; } } float ticks = (float)SDL_GetTicks() / 1000.0f; float elapsed = ticks - lastFrameTicks; lastFrameTicks = ticks; program.setModelMatrix(modelMatrix); program.setProjectionMatrix(projectionMatrix); program.setViewMatrix(viewMatrix); glUseProgram(program.programID); glClearColor(0.2f, 0.2f, 0.2, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE); // BALL float vertices[] = { -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f }; glVertexAttribPointer(program.positionAttribute, 2, GL_FLOAT, false, 0, vertices); glEnableVertexAttribArray(program.positionAttribute); float texCoords[] = { 0.0, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0 }; glVertexAttribPointer(program.texCoordAttribute, 2, GL_FLOAT, false, 0, texCoords); glEnableVertexAttribArray(program.texCoordAttribute); glBindTexture(GL_TEXTURE_2D, textureID); glDrawArrays(GL_TRIANGLES, 0, 6); glDisableVertexAttribArray(program.positionAttribute); glDisableVertexAttribArray(program.texCoordAttribute); program.setModelMatrix(panelOneMatrix); // PANEL ONE float panelVTwo[] = { -0.1f, -0.75f, 0.1f, 0.75f, -0.1f, 0.75f, 0.1f, 0.75f, -0.1f, -0.75f, 0.1f, -0.75f }; glVertexAttribPointer(program.positionAttribute, 2, GL_FLOAT, false, 0, panelVTwo); glEnableVertexAttribArray(program.positionAttribute); float texPanelOne[] = { 0.0, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0 }; glVertexAttribPointer(program.texCoordAttribute, 2, GL_FLOAT, false, 0, texPanelOne); glEnableVertexAttribArray(program.texCoordAttribute); panelOneMatrix.Translate(panelOne->starty, panelOne->pos, 0.0f); glBindTexture(GL_TEXTURE_2D, panelTexID); glDrawArrays(GL_TRIANGLES, 0, 6); glDisableVertexAttribArray(program.positionAttribute); glDisableVertexAttribArray(program.texCoordAttribute); program.setModelMatrix(panelTwoMatrix); // PANEL TWO float panelVOne[] = { -0.1f, -0.75f, 0.1f, 0.75f, -0.1f, 0.75f, 0.1f, 0.75f, -0.1f, -0.75f, 0.1f, -0.75f }; glVertexAttribPointer(program.positionAttribute, 2, GL_FLOAT, false, 0, panelVOne); glEnableVertexAttribArray(program.positionAttribute); float texPanelTwo[] = { 0.0, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0 }; glVertexAttribPointer(program.texCoordAttribute, 2, GL_FLOAT, false, 0, texPanelTwo); glEnableVertexAttribArray(program.texCoordAttribute); glBindTexture(GL_TEXTURE_2D, panelTexID); glDrawArrays(GL_TRIANGLES, 0, 6); glDisableVertexAttribArray(program.positionAttribute); glDisableVertexAttribArray(program.texCoordAttribute); modelMatrix.identity(); panelOneMatrix.identity(); panelTwoMatrix.identity(); panelOne->update(); panelTwo->update(); panelOne->pos += panelOne->vel*elapsed; panelTwo->pos += panelTwo->vel*elapsed; ball->update(); ball->xPos += ball->xVel*elapsed; ball->yPos += ball->yVel*elapsed; angle += elapsed; modelMatrix.Translate(ball->xPos, ball->yPos, 0.0f); modelMatrix.Scale(0.6f, 0.6f, 1.0f); modelMatrix.Rotate(angle); panelOneMatrix.Translate(panelOne->starty, panelOne->pos, 0.0f); panelOneMatrix.Scale(0.5f, 0.5f, 1.0f); panelTwoMatrix.Translate(panelTwo->starty, panelTwo->pos, 0.0f); panelTwoMatrix.Scale(0.5f, 0.5f, 1.0f); SDL_GL_SwapWindow(displayWindow); } SDL_Quit(); return 0; }
//----------------------------------------------------------------------------- // Purpose: Callback for when the panel size has been changed //----------------------------------------------------------------------------- void EditablePanel::OnSizeChanged(int wide, int tall) { BaseClass::OnSizeChanged(wide, tall); InvalidateLayout(); for (int i = 0; i < GetChildCount(); i++) { // perform auto-layout on the child panel Panel *child = GetChild(i); if ( !child ) continue; int x, y, w, h; child->GetBounds( x, y, w, h ); int px, py; child->GetPinOffset( px, py ); int ox, oy; child->GetResizeOffset( ox, oy ); int ex; int ey; AutoResize_e resize = child->GetAutoResize(); bool bResizeHoriz = ( resize == AUTORESIZE_RIGHT || resize == AUTORESIZE_DOWNANDRIGHT ); bool bResizeVert = ( resize == AUTORESIZE_DOWN || resize == AUTORESIZE_DOWNANDRIGHT ); PinCorner_e pinCorner = child->GetPinCorner(); if ( pinCorner == PIN_TOPRIGHT || pinCorner == PIN_BOTTOMRIGHT ) { // move along with the right edge ex = wide + px; x = bResizeHoriz ? ox : ex - w; } else { x = px; ex = bResizeHoriz ? wide + ox : px + w; } if ( pinCorner == PIN_BOTTOMLEFT || pinCorner == PIN_BOTTOMRIGHT ) { // move along with the right edge ey = tall + py; y = bResizeVert ? oy : ey - h; } else { y = py; ey = bResizeVert ? tall + oy : py + h; } // Clamp.. if ( ex < x ) { ex = x; } if ( ey < y ) { ey = y; } child->SetBounds( x, y, ex - x, ey - y ); child->InvalidateLayout(); } Repaint(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool BuildGroup::MousePressed(MouseCode code, Panel *panel) { Assert(panel); if ( !m_hBuildDialog.Get() ) { if ( panel->GetParent() ) { EditablePanel *ep = dynamic_cast< EditablePanel * >( panel->GetParent() ); if ( ep ) { BuildGroup *bg = ep->GetBuildGroup(); if ( bg && bg != this ) { bg->MousePressed( code, panel ); } } } return false; } // if people click on the base build dialog panel. if (panel == m_hBuildDialog) { // hide the click menu if its up ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("HideNewControlMenu"), NULL); return true; } // don't select unnamed items if (strlen(panel->GetName()) < 1) return true; bool shift = ( input()->IsKeyDown(KEY_LSHIFT) || input()->IsKeyDown(KEY_RSHIFT) ); if (!shift) { _controlGroup.RemoveAll(); } // Show new ctrl menu if they click on the bg (not on a subcontrol) if ( code == MOUSE_RIGHT && panel == GetContextPanel()) { // trigger a drop down menu to create new controls ivgui()->PostMessage (m_hBuildDialog->GetVPanel(), new KeyValues("ShowNewControlMenu"), NULL); } else { // don't respond if we click on ruler numbers if (_showRulers) // rulers are visible { for ( int i=0; i < 4; i++) { if ( panel == _rulerNumber[i]) return true; } } _dragging = true; _dragMouseCode = code; ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("HideNewControlMenu"), NULL); int x, y; input()->GetCursorPos(x, y); _dragStartCursorPos[0] = x; _dragStartCursorPos[1] = y; input()->SetMouseCapture(panel->GetVPanel()); _groupDeltaX.RemoveAll(); _groupDeltaY.RemoveAll(); // basepanel is the panel that all the deltas will be calculated from. // it is the last panel we clicked in because if we move the panels as a group // it would be from that one Panel *basePanel = NULL; // find the panel we clicked in, that is the base panel // it might already be in the group for (int i=0; i< _controlGroup.Count(); ++i) { if (panel == _controlGroup[i].Get()) { basePanel = panel; break; } } // if its not in the group we just added this panel. get it in the group if (basePanel == NULL) { PHandle temp; temp = panel; _controlGroup.AddToTail(temp); basePanel = panel; } basePanel->GetPos(x,y); _dragStartPanelPos[0]=x; _dragStartPanelPos[1]=y; basePanel->GetSize( _dragStartPanelSize[ 0 ], _dragStartPanelSize[ 1 ] ); // figure out the deltas of the other panels from the base panel for (int i=0; i<_controlGroup.Count(); ++i) { int cx, cy; _controlGroup[i].Get()->GetPos(cx, cy); _groupDeltaX.AddToTail(cx - x); _groupDeltaY.AddToTail(cy - y); } // if this panel wasn't already selected update the buildmode dialog controls to show its info if(_currentPanel != panel) { _currentPanel = panel; if ( m_hBuildDialog ) { // think this is taken care of by SetActiveControl. //ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("ApplyDataToControls"), NULL); KeyValues *keyval = new KeyValues("SetActiveControl"); keyval->SetPtr("PanelPtr", GetCurrentPanel()); ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), keyval, NULL); } } // store undo information upon panel selection. ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("StoreUndo"), NULL); panel->RequestFocus(); } return true; }
void Project::New(wxWindow *parent, MenuState *state, const wxString& type) { if (l_instance != NULL) { DESTROY(l_instance); } l_instance = NEW(Project, (parent, type)); // Load the XML project description. Debug::Printf(TXT("Parsing \"%s\".\n"), l_Types[type].c_str()); wxXmlDocument xml; if (!xml.Load(l_Types[type])) { THROW(TXT("Couldn't parse the XML file.")); } if (xml.GetRoot()->GetName() != wxT("project")) { THROW(TXT("Root node isn't <project>.")); } //wxArrayString groups = NodeLibrary::AddUserNodes(); //wxString grpfile(g_FragmentShaderLibPath); //grpfile.Append(wxT("nodes\\user.xml")); //wxArrayString groups = NodeLibrary::Add(grpfile); wxXmlNode *child = xml.GetRoot()->GetChildren(); while (child != 0) { if (child->GetType() == wxXML_COMMENT_NODE) { child = child->GetNext(); continue; } if (child->GetName() == wxT("panel")) { wxString name; if (!child->GetPropVal(wxT("name"), &name)) { THROW(TXT("Couldn't find attribute 'name' in element <panel>.")); } Panel *panel = NEW(Panel, (l_instance, state->Clone())); panel->Freeze(); l_instance->AddPage(panel, name); Debug::Printf(TXT("Panel \"%s\" (%p) created.\n"), name.c_str(), panel); wxXmlNode *child2 = child->GetChildren(); /* for (size_t i = 0; i < groups.GetCount(); i++) { panel->AddToTree(groups[i]); Debug::Printf(TXT("Group \"%s\" added to panel %p.\n"), groups[i].c_str(), panel); } */ while (child2 != 0) { if (child2->GetType() == wxXML_COMMENT_NODE) { child2 = child2->GetNext(); continue; } if (child2->GetName() == wxT("add-library")) { wxString path; if (!child2->GetPropVal(wxT("path"), &path)) { THROW(TXT("Couldn't find attribute 'path' in element <add-library>.")); } panel->LoadLibrary(path); Debug::Printf(TXT("Library \"%s\" added to panel %p.\n"), path, panel); } else if (child2->GetName() == wxT("add-node")) { wxString type; if (!child2->GetPropVal(wxT("type"), &type)) { THROW(TXT("Couldn't find attribute 'type' in element <add-node>.")); } wxString deletable = child2->GetPropVal(wxT("deletable"), wxT("false")); panel->AddNode(type, deletable == wxT("true")); Debug::Printf(TXT("Node \"%s\" added to panel %p.\n"), type.c_str(), panel); } else { Debug::Printf(TXT("\tInvalid element <%s> in <panel>.\n"), child2->GetName().c_str()); } child2 = child2->GetNext(); } panel->Thaw(); } else { Debug::Printf(TXT("\tInvalid element <%s> in <project>.\n"), child->GetName().c_str()); } child = child->GetNext(); } // Delete the menu state (it has been cloned for each panel.) DESTROY(state); // Load the panels configuration. l_instance->LoadConfig(); // Clear Undo data of all panels. size_t count = l_instance->GetPageCount(); for (size_t index = 0; index < count; index++) { Panel *panel = (Panel *)l_instance->GetPage(index); panel->GetUndoerCtrl()->Clear(); } }
void search() { Panel search; search.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN);; search.show(); search.shape("SEARCH"); Panel move; move.init(220,120,525,455,OUT,THIN); move.show( ); move.shape("SEARCH"); settextstyle(1,0,1); tsearch(); int cnt=0; while((!kbhit())&&(!(leftmousekeypressed()))) cnt++; Panel scribble; scribble.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN); scribble.show(); }
virtual void handleEvent(SDL_Event& e) { //If an event was detected for this window if (e.window.windowID != mWindowID) return; if (e.type == SDL_WINDOWEVENT) { //Caption update flag bool updateCaption = false; switch (e.window.event) { //Window appeared case SDL_WINDOWEVENT_SHOWN: mShown = true; break; //Window disappeared case SDL_WINDOWEVENT_HIDDEN: mShown = false; break; //Get new dimensions and repaint case SDL_WINDOWEVENT_SIZE_CHANGED: mWidth = e.window.data1; mHeight = e.window.data2; SDL_RenderPresent(mRenderer); break; //Repaint on expose case SDL_WINDOWEVENT_EXPOSED: SDL_RenderPresent(mRenderer); break; //Mouse enter case SDL_WINDOWEVENT_ENTER: mMouseFocus = true; updateCaption = true; break; //Mouse exit case SDL_WINDOWEVENT_LEAVE: mMouseFocus = false; updateCaption = true; break; //Keyboard focus gained case SDL_WINDOWEVENT_FOCUS_GAINED: mKeyboardFocus = true; updateCaption = true; break; //Keyboard focus lost case SDL_WINDOWEVENT_FOCUS_LOST: mKeyboardFocus = false; updateCaption = true; break; //Window minimized case SDL_WINDOWEVENT_MINIMIZED: mMinimized = true; break; //Window maxized case SDL_WINDOWEVENT_MAXIMIZED: mMinimized = false; break; //Window restored case SDL_WINDOWEVENT_RESTORED: mMinimized = false; break; //Hide and quit on close case SDL_WINDOWEVENT_CLOSE: SDL_HideWindow(mWindow); mClosed = true; break; } //Demo Update window caption with new data if (updateCaption) { std::stringstream caption; caption << mTitle << " - ID: " << mWindowID << " MouseFocus:" << ((mMouseFocus) ? "On" : "Off") << " KeyboardFocus:" << ((mKeyboardFocus) ? "On" : "Off"); SDL_SetWindowTitle(mWindow, caption.str().c_str()); } } //Case of Panels int x, y; //Get mouse position SDL_GetMouseState(&x, &y); for (std::list<Panel*>::iterator iter = pList_->begin(); iter != pList_->end(); iter++) { Panel *p = (*iter); p->handleEvent(e, x - p->getX(), y - p->getY()); } }