/// Sets the currently active tool /// @param tool - The index of the tool to be used. /// @param show - should we update the button display? void ToolsToolBar::SetCurrentTool(int tool, bool show) { //In multi-mode the current tool is shown by the //cursor icon. The buttons are not updated. bool leavingMulticlipMode = IsDown(multiTool) && show && tool != multiTool; if (leavingMulticlipMode) mTool[multiTool]->PopUp(); if (tool != mCurrentTool || leavingMulticlipMode) { if (show) mTool[mCurrentTool]->PopUp(); mCurrentTool=tool; if (show) mTool[mCurrentTool]->PushDown(); } //JKC: ANSWER-ME: Why is this RedrawAllProjects() line required? //msmeyer: I think it isn't, we leave it out for 1.3.1 (beta), and // we'll see if anyone complains. // RedrawAllProjects(); //msmeyer: But we instruct the projects to handle the cursor shape again if (show) { RefreshCursorForAllProjects(); gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"), IsDown(multiTool)); gPrefs->Flush(); } }
void ToolsToolBar::OnTool(wxCommandEvent & evt) { mCurrentTool = evt.GetId() - firstTool; for (int i = 0; i < numTools; i++) if (i == mCurrentTool) mTool[i]->PushDown(); else mTool[i]->PopUp(); #ifdef EXPERIMENTAL_SCRUBBING_BASIC if (0 != mCurrentTool) { AudacityProject *p = GetActiveProject(); if (p) { TrackPanel *tp = p->GetTrackPanel(); if (tp) { tp->StopScrubbing(); } } } #endif RedrawAllProjects(); gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"), IsDown(multiTool)); gPrefs->Flush(); }
AUI_ERRCODE aui_Button::DrawThis( aui_Surface *surface, sint32 x, sint32 y ) { if ( IsHidden() ) return AUI_ERRCODE_OK; if ( !surface ) surface = m_window->TheSurface(); RECT rect = { 0, 0, m_width, m_height }; OffsetRect( &rect, m_x + x, m_y + y ); ToWindow( &rect ); DrawThisStateImage( IsDown() ? 1 : 0, surface, &rect ); DrawThisText( surface, &rect ); if ( surface == m_window->TheSurface() ) m_window->AddDirtyRect( &rect ); return AUI_ERRCODE_OK; }
void CrBattleCharacter::SetAngle(float angle) { //---ダウン中だったら向き設定無効 if(IsDown()) return; OnlyInfo.Angle = angle; }
/// Sets the currently active tool /// @param tool - The index of the tool to be used. /// @param show - should we update the button display? void ToolsToolBar::SetCurrentTool(int tool, bool show) { //In multi-mode the current tool is shown by the //cursor icon. The buttons are not updated. #ifdef EXPERIMENTAL_SCRUBBING_BASIC if (tool != selectTool) { AudacityProject *p = GetActiveProject(); if (p) { TrackPanel *tp = p->GetTrackPanel(); if (tp) { tp->StopScrubbing(); } } } #endif bool leavingMulticlipMode = IsDown(multiTool) && show && tool != multiTool; if (leavingMulticlipMode) mTool[multiTool]->PopUp(); if (tool != mCurrentTool || leavingMulticlipMode) { if (show) mTool[mCurrentTool]->PopUp(); mCurrentTool=tool; if (show) mTool[mCurrentTool]->PushDown(); } //JKC: ANSWER-ME: Why is this RedrawAllProjects() line required? //msmeyer: I think it isn't, we leave it out for 1.3.1 (beta), and // we'll see if anyone complains. // RedrawAllProjects(); //msmeyer: But we instruct the projects to handle the cursor shape again if (show) { RefreshCursorForAllProjects(); gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"), IsDown(multiTool)); gPrefs->Flush(); } }
bool Input::IsPressed(int key) { if(IsDown(key) && !downkeys[key]) { downkeys[key] = true; return true; } else return false; }
int ToolsToolBar::GetDownTool() { int tool; for (tool = firstTool; tool <= lastTool; tool++) if (IsDown(tool)) return tool; return firstTool; // Should never happen }
//---パターンを自動設定 void CrBattleCharacter::SetPatternAuto(void) { if(!GetDrawType()){ if(IsDown()){ SetPattern(4); } else { SetPattern(0); } } else { SetPattern(0); } }
BOOL CTable::HaveDown(BYTE value) { int i,j; for (i=0;i<8;i++) for (j=0;j<8;j++) { if (IsDown(j,i,value)) { return TRUE; } } return FALSE; }
/* * KeysDown: Return # of keys that are down. Since some keys (like ALT) * actually correspond to more than one key value, we check only key * values in [1, 127]. */ int KeysDown(void) { int count = 0, i; BYTE keys[NUM_KEYS]; GetKeyboardState(keys); for (i = 1; i < NUM_REAL_KEYS; i++) if (IsDown(keys[i])) count++; return count; }
void ToolsToolBar::OnTool(wxCommandEvent & evt) { mCurrentTool = evt.GetId() - firstTool; for (int i = 0; i < numTools; i++) if (i == mCurrentTool) mTool[i]->PushDown(); else mTool[i]->PopUp(); RedrawAllProjects(); gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"), IsDown(multiTool)); gPrefs->Flush(); }
bool pawsButton::OnMouseDown(int button, int modifiers, int x, int y) { if(!enabled) { return true; } else if(button == csmbWheelUp || button == csmbWheelDown || button == csmbHWheelLeft || button == csmbHWheelRight) { if(parent) { return parent->OnMouseDown(button, modifiers, x, y); } else { return false; } } // Play a sound PawsManager::GetSingleton().GetSoundManager()->PlaySound(sound_click, false, iSoundManager::GUI_SNDCTRL); if(toggle) { SetState(!IsDown()); } else if(changeOnMouseOver) { SetState(false, false); } else { SetState(true, false); } if(notify != NULL) { return notify->CheckButtonPressed(button, modifiers, this); } else if(parent) { return parent->CheckButtonPressed(button, modifiers, this); } return false; }
void WndButton::OnPaint(Canvas &canvas) { const bool pressed = IsDown(); const bool focused = HasCursorKeys() ? HasFocus() : pressed; PixelRect rc = canvas.GetRect(); renderer.DrawButton(canvas, rc, focused, pressed); // If button has text on it const tstring caption = GetText(); if (caption.empty()) return; rc = renderer.GetDrawingRect(rc, pressed); canvas.SetBackgroundTransparent(); if (!IsEnabled()) canvas.SetTextColor(look.button.disabled.color); else if (focused) canvas.SetTextColor(look.button.focused.foreground_color); else canvas.SetTextColor(look.button.standard.foreground_color); canvas.Select(*(look.button.font)); #ifndef USE_GDI canvas.DrawFormattedText(&rc, caption.c_str(), GetTextStyle()); #else unsigned style = DT_CENTER | DT_NOCLIP | DT_WORDBREAK; PixelRect text_rc = rc; canvas.DrawFormattedText(&text_rc, caption.c_str(), style | DT_CALCRECT); text_rc.right = rc.right; PixelScalar offset = rc.bottom - text_rc.bottom; if (offset > 0) { offset /= 2; text_rc.top += offset; text_rc.bottom += offset; } canvas.DrawFormattedText(&text_rc, caption.c_str(), style); #endif }
void DebugControlCamera(GameState* game_state, Camera* camera) { if(IsDown(game_state->input, KeyCode_LEFT)) { camera->position.x -= 0.1f; } if(IsDown(game_state->input, KeyCode_RIGHT)) { camera->position.x += 0.1f; } if(IsDown(game_state->input, KeyCode_UP)) { if (IsDown(game_state->input, KeyCode_CONTROL)) { camera->position.y += 0.1f; } else { camera->viewport_size *= 1.1f; } } if(IsDown(game_state->input, KeyCode_DOWN)) { if (IsDown(game_state->input, KeyCode_CONTROL)) { camera->position.y -= 0.1f; } else { camera->viewport_size *= 0.9f; } } }
// int main(int argc, char* argv[]) int GameMain() { // assert(argc || argv[0]); // Fixes the compiler complaining about unused values; GameState* game_state = CreateNewGameState("EnGen", 1600, 900); Renderer* renderer = game_state->renderer; game_state->active_scene = PushScene(&game_state->permanent_memory, MAX_GAME_ENTITES); TileMap* tilemap = game_state->active_scene->tilemap; for (int32 i = 0; i < 10; ++i) { Vec2 pos = { (float)i, 2.f }; AddTileToMap(tilemap, pos); } for (int32 i = 0; i < 10; ++i) { Vec2 pos = { 0, (float)i }; AddTileToMap(tilemap, pos); } for (int32 i = 0; i < 10; ++i) { Vec2 pos = { 10.f, (float)i }; AddTileToMap(tilemap, pos); } UIWindow* ui = PushStruct(&game_state->permanent_memory, UIWindow); SetTitle(ui, "Editor UI!"); SetSize(ui, { 0.1f, 0.3f, 0.2f, 0.2f }, 0.05f); UIWindow* ui2 = PushStruct(&game_state->permanent_memory, UIWindow); SetTitle(ui2, "Editor UI2!"); SetSize(ui2, { 0.2f, 0.3f, 0.2f, 0.2f }, 0.05f); InitializeDebugConsole(); #if 0 InitializeAudio(); char* test_sound_file = "C:\\projects\\imperial_march.wav"; bool test_sound_loaded = LoadWavFile(test_sound_file); if(test_sound_loaded) { printf("Loaded File\n"); } PauseAudio(false); #endif Camera default_camera = {}; // maybe put this in game_state? default_camera.position = vec2(0, 0); default_camera.viewport_size.x = 16; default_camera.viewport_size.y = 9; uint32 frame_count = 0; uint32 fps = 0; double last_fps_time = 0; bool running = true; while (running) { ProfileBeginFrame(); ProfileBeginSection(Profile_Frame); ProfileBeginSection(Profile_Input); Platform_RunMessageLoop(game_state->input); Camera* draw_camera = game_state->active_camera ? game_state->active_camera : &default_camera; game_state->window.resolution = Platform_GetResolution(); UpdateMouseWorldPosition(game_state->input, game_state->window.resolution, draw_camera->viewport_size, draw_camera->position); ProfileEndSection(Profile_Input); Vec2i mouse_pos = MousePosition(game_state->input); //DebugPrintf("Mouse World Position: (%.2f, %.2f)", mouse_pos.x, mouse_pos.y); DebugPrintf("Mouse World Position: (%d, %d)", mouse_pos.x, mouse_pos.y); DebugPrintf("Main Camera Position: (%.2f, %.2f)", default_camera.position.x, default_camera.position.y); DebugPrintf("Key Pressed: %s", IsDown(game_state->input, KeyCode_a) ? "TRUE" : "FALSE"); if (OnDown(game_state->input, KeyCode_ESCAPE)) { running = false; break; } #if 0 // TODO: Platform layer if (OnDown(game_state->input, KeyCode_z)) { ForceColorClear(); SwapBuffer(game_state); //WindowSetScreenMode(&game_state->window, ScreenMode_Windowed); } else if (OnDown(game_state->input, KeyCode_c)) { ForceColorClear(); SwapBuffer(game_state); //WindowSetScreenMode(&game_state->window, ScreenMode_Borderless); } #endif static bool draw_debug = true; if (OnDown(game_state->input, KeyCode_BACKQUOTE)) { draw_debug = !draw_debug; } Renderer* debug_renderer = draw_debug ? renderer : 0; TimeBeginFrame(game_state); // Update the scene first, pushing draw calls if necessary. // Then call begin_frame which builds matrices and clears buffers; float current_time = CurrentTime(game_state); if (current_time - last_fps_time > 1.0f) { last_fps_time = current_time; fps = frame_count; frame_count = 0; } frame_count++; DebugPrintf("FPS: \t\t%d \tFrames: \t%d", fps, FrameCount(game_state)); DebugControlCamera(game_state, &default_camera); // TODO(cgenova): separate update and render calls so that things can be set up when rendering begins; BeginFrame(renderer, &game_state->window); ProfileBeginSection(Profile_SceneUpdate); DebugPrintPushColor(vec4(1.0f, 0, 0, 1.0f)); DebugPrintf("Active scene entity usage: (%d / %d)", game_state->active_scene->active_entities, MAX_GAME_ENTITES); DebugPrintPopColor(); UpdateSceneEntities(game_state, game_state->active_scene); DrawSceneEntities(game_state->active_scene, renderer); ProfileEndSection(Profile_SceneUpdate); #if 1 // Spaghetti test const size_t num_verts = 200; static SimpleVertex v[num_verts]; static bool initialized = false; if (!initialized) { initialized = true; for (uint32 i = 0; i < num_verts; ++i) { SimpleVertex verts = {}; verts.position = vec2((float)(i / 50.f) - 2.f, (float)i); verts.color = vec4(1, 1, 0, 1.f); v[i] = verts; } } else { for (uint32 i = 0; i < num_verts; ++i) { v[i].position.y = sin(CurrentTime(game_state) + i / (PI * 20)); } } PrimitiveDrawParams spaghetti_params = {}; spaghetti_params.line_draw_flags |= PrimitiveDraw_Smooth; // spaghetti_params.line_draw_flags |= Draw_ScreenSpace; spaghetti_params.line_width = 0; DrawLine(renderer, v, num_verts, spaghetti_params); #endif DrawTileMap(game_state, game_state->active_scene->tilemap); UpdateUIWindow(game_state, ui); UpdateUIWindow(game_state, ui2); RenderDrawBuffer(renderer, draw_camera); ProfileEndSection(Profile_Frame); ProfileEndFrame(debug_renderer, TARGET_FPS); DebugDrawConsole(debug_renderer); // NOTE: // For drawing Debug info, the profiling in this section will be discarded, // but it is only drawing text and the debug graph. RenderDrawBuffer(renderer, draw_camera); SwapBuffer(game_state); // TODO(cgenova): High granularity sleep function! ResetArena(&game_state->temporary_memory); }// End main loop return 1; }
void ClsFlatButton::PaintControl( ClsDC *pDC ) { // Get the client rectangle. ClsRect rc = GetClientRect(); // Any room to render in? if ( ! rc.IsEmpty()) { // Create an off-screen buffer. ClsBufferDC dc( *pDC, rc ); // Snapshot the DC. int sDC = dc.SaveDC(); // Render the frame. if ( ! m_bXPStyle ) RenderFrame( &dc, rc ); else { // Only when were hot or down. COLORREF crFg, crBg; if (( IsHot() || IsDown()) && IsWindowEnabled()) { crFg = XPColors.GetXPColor( ClsXPColors::XPC_OUTER_SELECTION ); crBg = XPColors.GetXPColor( IsDown() ? ClsXPColors::XPC_INNER_CHECKED_SELECTED : ClsXPColors::XPC_INNER_SELECTION ); } else { // Default colors... crFg = ( IsDefault() && IsWindowEnabled() && ! m_bXPDefault ) ? XPColors.GetXPColor( ClsXPColors::XPC_OUTER_SELECTION ) : XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_DISABLED ); crBg = ::GetSysColor( COLOR_BTNFACE ); } // Render rectangle. dc.OutlinedRectangle( rc, crFg, crBg ); } // Determine rendering flags. DWORD dwFlags = 0; if ( ! IsWindowEnabled()) dwFlags |= ClsDrawTools::CDSF_DISABLED; if ( IsDown() && ! ThemingAPI.IsThemingEnabled()) dwFlags |= ClsDrawTools::CDSF_DOWNPRESSED; if ( GetUIState() & UISF_HIDEACCEL ) dwFlags |= ClsDrawTools::CDSF_HIDEACCEL; if ( IsHot()) dwFlags |= ClsDrawTools::CDSF_HOT; // Do we have any images? if ( m_hImages ) { // Copy the client rectangle. ClsRect rcimg( rc ); // We need to know the size of the images // in the image list. int cx, cy; ::ImageList_GetIconSize( m_hImages, &cx, &cy ); // Determine the place at which we render the images. rcimg.Offset( ::GetSystemMetrics( SM_CXFRAME ), 0 ); rcimg.Right() = rcimg.Left() + cx; // Adjust label rectangle. rc.Left() += cx + 4; // Render the image. if ( ! m_bXPStyle ) ClsDrawTools::RenderBitmap( dc, m_hImages, ( IsHot() || IsDown()) ? m_aImageIndex[ FIIF_HOT ] : m_aImageIndex[ FIIF_NORMAL ], rcimg, dwFlags ); else ClsDrawTools::RenderXPBitmap( dc, m_hImages, ( IsHot() || IsDown()) ? m_aImageIndex[ FIIF_HOT ] : m_aImageIndex[ FIIF_NORMAL ], rcimg, dwFlags ); } // Render the caption. ClsString str( m_hWnd ); // Anything to render? if ( str.GetStringLength()) { // Deflate the label rectangle. rc.Deflate( 3, 3 ); // Do we have the focus? if ( HasFocus() && ! ( GetUIState() & UISF_HIDEFOCUS ) && ! m_bPanelHeader ) dc.DrawFocusRect( rc ); // Setup the font to use. ClsFont font; GetFont( font ); ClsSelector sel( &dc, font ); // Render transparently. dc.SetBkMode( TRANSPARENT ); // We must not use the disabled flag if we are // rendering XP style... if ( m_bXPStyle ) dwFlags &= ~( ClsDrawTools::CDSF_DISABLED | ClsDrawTools::CDSF_DOWNPRESSED ); // Set text color. COLORREF cr = GetSysColor( IsWindowEnabled() ? COLOR_BTNTEXT : COLOR_GRAYTEXT ); if ( IsDown() && m_bXPStyle ) cr = XPColors.GetXPColor( ClsXPColors::XPC_TEXT_BACKGROUND ); if ( IsHot() || IsDown()) cr = m_crHotLabelColor == CLR_NONE ? cr : m_crHotLabelColor; else cr = m_crLabelColor == CLR_NONE ? cr : m_crLabelColor; dc.SetTextColor( cr ); // Render the caption. ClsDrawTools::RenderText( dc, str, rc, dwFlags ); } // Restore device context. dc.RestoreDC( sDC ); } }
/* * HandleKeys: Check state of keyboard and perform actions that correspond * to keys that are down. */ void HandleKeys(Bool poll) { Bool norepeat; BYTE keys[NUM_KEYS]; int action, i, j; DWORD now; int actions[MAX_ACTIONS]; // Holds actions we've already done int num_actions; // Number of valid entries in actions Bool moved, turned, already_done; KeyTable table; void *action_data; list_type l; /* If main window no longer has the focus, don't read keyboard */ if (GetFocus() != hMain) return; now = timeGetTime(); num_actions = 0; GetKeyboardState(keys); // Go through all key tables that match the current state for (l = key_tables; l != NULL; l = l->next) { KeyTableListEntry *entry; entry = (KeyTableListEntry *) (l->data); if (entry->state != GameGetState()) continue; table = entry->table; /* Perform action for ALL keys that are down; this allows multiple arrow keys to work */ /* First, mark all actions that correspond to keys that are down */ norepeat = False; moved = turned = False; for (i = 1; i < NUM_KEYS; i++) { if (!IsDown(keys[i])) continue; action = TranslateKey(i, table, &action_data); if (action == A_NOACTION) continue; // Don't constantly toggle tab or mouselook if key held down. if ((IsTabAction(action) || IsMouseLookAction(action)) && poll) continue; // Perform action at most once already_done = False; for (j=0; j < num_actions; j++) if (actions[j] == action) already_done = True; if (already_done || num_actions == MAX_ACTIONS) continue; actions[num_actions++] = action; /* Only repeat for moving actions and a few others */ if (!RepeatAction(action)) if (now - last_norepeat_time >= KEY_NOREPEAT_INTERVAL) norepeat = True; else continue; // Action retried too soon if (IsMoveAction(action)) if (moved) continue; else { int tempKey = i; int tempAction; moved = True; for (; tempKey < NUM_KEYS; tempKey++) { if (!IsDown(keys[tempKey])) continue; tempAction = TranslateKey(tempKey, table, &action_data); if (IsMoveAction(tempAction)) { switch (action) { case A_FORWARD: switch(tempAction) { case A_SLIDELEFT: action = A_SLIDELEFTFORWARD; tempKey = NUM_KEYS; break; case A_SLIDERIGHT: action = A_SLIDERIGHTFORWARD; tempKey = NUM_KEYS; break; } case A_FORWARDFAST: switch(tempAction) { case A_SLIDELEFTFAST: action = A_SLIDELEFTFORWARDFAST; tempKey = NUM_KEYS; break; case A_SLIDERIGHTFAST: action = A_SLIDERIGHTFORWARDFAST; tempKey = NUM_KEYS; break; } break; case A_BACKWARD: switch(tempAction) { case A_SLIDELEFT: action = A_SLIDELEFTBACKWARD; tempKey = NUM_KEYS; break; case A_SLIDERIGHT: action = A_SLIDERIGHTBACKWARD; tempKey = NUM_KEYS; break; } case A_BACKWARDFAST: switch(tempAction) { case A_SLIDELEFTFAST: action = A_SLIDELEFTBACKWARDFAST; tempKey = NUM_KEYS; break; case A_SLIDERIGHTFAST: action = A_SLIDERIGHTBACKWARDFAST; tempKey = NUM_KEYS; break; } break; case A_SLIDELEFT: switch(tempAction) { case A_FORWARD: action = A_SLIDELEFTFORWARD; tempKey = NUM_KEYS; break; case A_BACKWARD: action = A_SLIDELEFTBACKWARD; tempKey = NUM_KEYS; break; } break; case A_SLIDELEFTFAST: switch(tempAction) { case A_FORWARDFAST: action = A_SLIDELEFTFORWARDFAST; tempKey = NUM_KEYS; break; case A_BACKWARDFAST: action = A_SLIDELEFTBACKWARDFAST; tempKey = NUM_KEYS; break; } break; case A_SLIDERIGHT: switch(tempAction) { case A_FORWARD: action = A_SLIDERIGHTFORWARD; tempKey = NUM_KEYS; break; case A_BACKWARD: action = A_SLIDERIGHTBACKWARD; tempKey = NUM_KEYS; break; } break; case A_SLIDERIGHTFAST: switch(tempAction) { case A_FORWARDFAST: action = A_SLIDERIGHTFORWARDFAST; tempKey = NUM_KEYS; break; case A_BACKWARDFAST: action = A_SLIDERIGHTBACKWARDFAST; tempKey = NUM_KEYS; break; } break; } } } } if (IsTurnAction(action)) if (turned) continue; else turned = True; // If we're doing a non-repeat action, remember the time so that we don't repeat it if (norepeat) last_norepeat_time = now; PerformAction(action, action_data); } } }