コード例 #1
0
ファイル: PlayListDlg.cpp プロジェクト: v-zaburdaev/Gsplayer2
void CPlayListDlg::OnMouseMove(int x, int y)
{
	if (m_fListDrag) {
		RECT rcItem;
		HWND hwndLV = GetDlgItem(m_hWnd, IDC_PLAY_LIST);
		if (!ListView_GetItemRect(hwndLV, 0, &rcItem, LVIR_BOUNDS))
			return;

		POINT pt = {x, y};
		ClientToScreen(m_hWnd, &pt);
		ScreenToClient(hwndLV, &pt);

		RECT rcLV;
		GetClientRect(hwndLV, &rcLV);
		if (pt.y < RECT_HEIGHT(&rcItem)) {
			ListView_Scroll(hwndLV, 0, -RECT_HEIGHT(&rcItem));
			OnUp(FALSE);
			m_nDragItem = max(m_nDragItem - 1, 0);
		}
		else if (pt.y > rcLV.bottom - RECT_HEIGHT(&rcItem)) {
			ListView_Scroll(hwndLV, 0, RECT_HEIGHT(&rcItem));
			OnDown(FALSE);
			m_nDragItem = min(m_nDragItem + 1, ListView_GetItemCount(hwndLV) - 1);
		}
		else {
			LVHITTESTINFO lvhti;
			lvhti.pt.x = pt.x; 
			lvhti.pt.y = pt.y;
			int nItem = ListView_HitTest(hwndLV, &lvhti);
			if (nItem == -1)
				return;

			if (nItem - m_nDragItem > 0) {
				for (int i = 0; i < nItem - m_nDragItem; i++)
					OnDown(FALSE);
				m_nDragItem = nItem;
			}
			else if (nItem - m_nDragItem < 0) {
				for (int i = 0; i < m_nDragItem - nItem; i++)
					OnUp(FALSE);
				m_nDragItem = nItem;
			}
		}
	}
}
コード例 #2
0
// 分发控制命令
void DispatchControl(CTRL _ctrl)
{
 switch(_ctrl)
 {
  case CTRL_ROTATE: OnRotate(); break;
  case CTRL_LEFT:  OnLeft(); break;
  case CTRL_RIGHT: OnRight(); break;
  case CTRL_DOWN:  OnDown(); break;
  case CTRL_SINK:  OnSink(); break;
  case CTRL_QUIT:  break;
 }
}
コード例 #3
0
ファイル: GUIControl.cpp プロジェクト: 0xheart0/xbmc
bool CGUIControl::OnAction(const CAction &action)
{
  if (HasFocus())
  {
    switch (action.GetID())
    {
    case ACTION_MOVE_DOWN:
      OnDown();
      return true;

    case ACTION_MOVE_UP:
      OnUp();
      return true;

    case ACTION_MOVE_LEFT:
      OnLeft();
      return true;

    case ACTION_MOVE_RIGHT:
      OnRight();
      return true;

    case ACTION_SHOW_INFO:
      return OnInfo();

    case ACTION_NAV_BACK:
      return OnBack();

    case ACTION_NEXT_CONTROL:
      OnNextControl();
      return true;

    case ACTION_PREV_CONTROL:
      OnPrevControl();
      return true;
    }
  }
  return false;
}
コード例 #4
0
ファイル: MenuBase.cpp プロジェクト: bsmr-games/Blood2
// Handles a key press.  Returns FALSE if the key was not processed through this method.
// Left, Up, Down, Right, and Enter are automatically passed through OnUp(), OnDown(), etc.
DBOOL CMenuBase::HandleKeyDown(int key, int rep)
{
	switch (key)
	{
	case VK_LEFT:
		{
			OnLeft();
			break;
		}
	case VK_RIGHT:
		{
			OnRight();
			break;
		}
	case VK_UP:
		{
			OnUp();
			break;
		}
	case VK_DOWN:
		{
			OnDown();
			break;
		}
	case VK_RETURN:
		{
			OnEnter();
			break;
		}
	default:
		{
			return m_listOption.HandleKeyDown(key, rep);
			break;
		}
	}

	// Handled the key
	return DTRUE;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: ravencgg/GLMario
// 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;
}
コード例 #6
0
ファイル: CMenuBase.cpp プロジェクト: Enucatl/bombermaaan-x
EMenuAction CMenuBase::Update (void)
{
    // Increase time elapsed in this menu mode
    m_MenuModeTime += m_pTimer->GetDeltaTime ();

    // If we don't have to exit this menu mode yet
    if (!m_HaveToExit)
    {
        // If NEXT control is pressed
        if (m_pInput->GetMainInput().TestNext())
        {
            // Don't play menu next sound because the choices of the user
            // could not be correct and we may have to play an error sound instead.
            
            OnNext ();
        }
        // If PREVIOUS control is pressed
        else if (m_pInput->GetMainInput().TestPrevious())
        {
            // Play the menu previous sound
            m_pSound->PlaySample (SAMPLE_MENU_PREVIOUS);

            OnPrevious ();
        }
        // If UP control is pressed
        else if (m_pInput->GetMainInput().TestUp())
        {
            // Play the menu beep sound
            m_pSound->PlaySample (SAMPLE_MENU_BEEP);

            OnUp ();
        }
        // If DOWN control is pressed
        else if (m_pInput->GetMainInput().TestDown())
        {
            // Play the menu beep sound
            m_pSound->PlaySample (SAMPLE_MENU_BEEP);

            OnDown ();
        }
        // If LEFT control is pressed
        else if (m_pInput->GetMainInput().TestLeft())
        {
            // Play the menu beep sound
            m_pSound->PlaySample (SAMPLE_MENU_BEEP);

            OnLeft ();
        }
        // If RIGHT control is pressed
        else if (m_pInput->GetMainInput().TestRight())
        {
            // Play the menu beep sound
            m_pSound->PlaySample (SAMPLE_MENU_BEEP);

            OnRight ();
        }

        // Update the menu screen
        OnUpdate ();
    }
    // If the transition has been entirely done (enough time has elapsed)
    else if (m_MenuModeTime >= m_ExitMenuModeTime + TRANSITION_DURATION)
    {
        // It's OK to exit now!
        // Ask for the menu action we saved
        return m_ExitMenuAction;
    }

    // Don't have to change menu mode nor game mode
    return MENUACTION_NONE;
}