Ejemplo n.º 1
0
	void init() {
		Scene<BLINN_PHONG> scene;

		auto texIds = scene.textures.createTextures<6>(
				{gli::load_dds("textures/tex1.dds"),
				 gli::load_dds("textures/tex2.dds"),
				 gli::load_dds("textures/tex3.dds"),
				 gli::load_dds("textures/bricks.dds"),
				 gli::load_dds("textures/bricks_normals.dds"),
				 gli::load_dds("textures/tex4.dds")});

		auto texId = scene.textures.createTexture(gli::load_dds("textures/bricks.dds"));

//		TiledMirrorBox::buildTiledMirrorBox<BLINN_PHONG>(scene,
//				glm::vec3(10.0, 10.0, 10.0), glm::ivec2(0, 0),
//				{{texIds[0], texIds[1], texIds[2],
//				  texIds[3], texIds[4], texIds[5]}});

		Kaleidescope::buildKaleidescope<BLINN_PHONG>(scene, std::array<unsigned, 3>{{6, 3, 2}}, 7.0f, 5.0f, texId);

		rndr = new Renderer<CL_DEVICE_TYPE_GPU, BLINN_PHONG>(
				scene, width, height,
				numReflectivePasses, maxViewDistance);

		arrow = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
		hand = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);

		initGL();
	}
Ejemplo n.º 2
0
bool RWindow::initializeSDL()
{
    SDL_DisplayMode current;

    if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        std::cerr << "Could not initialize SDL: " << SDL_GetError();
        std::cerr << std::endl;
        std::exit(1);
    }

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);

    if(SDL_GetCurrentDisplayMode(0, &current) != 0)
    {
        // In case of error...
        std::cerr << "Could not get display mode for video display: ";
        std::cerr << SDL_GetError() << std::endl;
        return false;
    }
    else
    {
        // Everything is normal
        m_width = current.w;
        m_height = current.h;
    }

    m_window = SDL_CreateWindow(
                m_title.data(),
                SDL_WINDOWPOS_UNDEFINED,
                SDL_WINDOWPOS_UNDEFINED,
                m_width, m_height,
                SDL_WINDOW_OPENGL |
                SDL_WINDOW_FULLSCREEN_DESKTOP |
                SDL_WINDOW_HIDDEN);

    if(m_window == nullptr)
    {
        std::cerr << "Could not iniialize SDL Window: " << SDL_GetError();
        std::cerr << std::endl;
        return false;
    }

    m_surface = SDL_GetWindowSurface(m_window);
    m_context = SDL_GL_CreateContext(m_window);

    //Init cursors
    m_systemCursors[0] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
    m_systemCursors[1] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
    m_systemCursors[2] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
    m_systemCursors[3] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
    m_systemCursors[4] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);

    for(unsigned i = 0; i < 4; ++i)
        m_customCursors[i] = nullptr;

    return true;
}
Ejemplo n.º 3
0
void PPDisplayDevice::initMousePointers()
{
	cursorStandard = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
	cursorResizeHoriz = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
	cursorEggtimer = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
	cursorHand = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
}
Ejemplo n.º 4
0
void Runtime::construct(const char *font, const char *boldFont) {
  logEntered();
  _state = kClosingState;
  _graphics = new Graphics(_window);

  _cursorHand = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
  _cursorArrow = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
  _cursorIBeam = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);

  if (_graphics && _graphics->construct(font, boldFont)) {
    int w, h;
    SDL_GetWindowSize(_window, &w, &h);
    _output = new AnsiWidget(w, h);
    if (_output && _output->construct()) {
      _eventQueue = new Stack<MAEvent *>();
      if (_eventQueue) {
        _state = kActiveState;
      }
    }
  } else {
    alert("Unable to start", "Font resource not loaded");
    fprintf(stderr, "failed to load: [%s] [%s]\n", font, boldFont);
    exit(1);
  }
}
Ejemplo n.º 5
0
void display_result_text(SDL_Renderer *pRenderer, Text *text, int *sleep, int16_t *counter) {

  /** Display the round winner by blinking the the text during a short time. **/

  if (*counter == 0) {

    /** First time this function is called:
     *  So we initialize the setting for an animation.
     *************************************************/

    game_control->is_animation_running=true ;

    game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW) ;
    SDL_SetCursor(game_control->cursor_type)  ;

    *sleep=1500000/3 ;  /** Mainloop pausing time high value needed for blinking. **/

    /** Setting up the text to display in relationship to the round result.
     *  Sea \file ./Utilities/text_utils.c
     **********************************************************************/
    configure_result_text(pRenderer, text, game_control->round_winner) ;

    (*counter) += 2 ;

  }

  if ((*counter) % 2 == 0 && game_control->is_animation_running && (*counter) < 11) {
    render_text(pRenderer, text) ;  /** Render text sea: \file ./Utilities/text_utils.c **/
  }

  (*counter)++ ;

  if (*counter == 13) {

    /** End of the animation: we reset settings. **/
 

    *sleep=10000 ;
    *counter=0 ;

    game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
  
    SDL_SetCursor(game_control->cursor_type)  ;

    game_control->is_animation_running = false ;

    game_control->GAME_STATUS = UPDATE_SCORE  ;

    return ;

  }

  return ;
}
Ejemplo n.º 6
0
static bool    ImGui_ImplSDL2_Init(SDL_Window* window)
{
    g_Window = window;

    // Setup back-end capabilities flags
    ImGuiIO& io = ImGui::GetIO();
    io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;       // We can honor GetMouseCursor() values (optional)
#if SDL_HAS_WARP_MOUSE_GLOBAL
    io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;        // We can honor io.WantSetMousePos requests (optional, rarely used)
#endif

    // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
    io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
    io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
    io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
    io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
    io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
    io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
    io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
    io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
    io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
    io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
    io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
    io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
    io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
    io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
    io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
    io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
    io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
    io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
    io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
    io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
    io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;

    io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
    io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
    io.ClipboardUserData = NULL;

    g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
    g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
    g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
    g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
    g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
    g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
    g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
    g_MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);

#ifdef _WIN32
    SDL_SysWMinfo wmInfo;
    SDL_VERSION(&wmInfo.version);
    SDL_GetWindowWMInfo(window, &wmInfo);
    io.ImeWindowHandle = wmInfo.info.win.window;
#else
    (void)window;
#endif

    return true;
}
Ejemplo n.º 7
0
static SDL_Cursor * GetLoadCursor( const EE_SYSTEM_CURSOR& cursor ) {
	if ( 0 == SDL_SYS_CURSORS[ cursor ] ) {
		SDL_SYS_CURSORS[ cursor ] = SDL_CreateSystemCursor( (SDL_SystemCursor)cursor );
	}

	return SDL_SYS_CURSORS[ cursor ];
}
Ejemplo n.º 8
0
void
loop()
{
    SDL_Event event;
        /* Check for events */
        while (SDL_PollEvent(&event)) {
            SDLTest_CommonEvent(state, &event, &done);

            if (event.type == SDL_WINDOWEVENT) {
                if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
                    SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
                    if (window) {
                        SDL_Log("Window %d resized to %dx%d\n",
                            event.window.windowID,
                            event.window.data1,
                            event.window.data2);
                    }
                }
                if (event.window.event == SDL_WINDOWEVENT_MOVED) {
                    SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
                    if (window) {
                        SDL_Log("Window %d moved to %d,%d (display %s)\n",
                            event.window.windowID,
                            event.window.data1,
                            event.window.data2,
                            SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window)));
                    }
                }
            }
            if (event.type == SDL_KEYUP) {
                SDL_bool updateCursor = SDL_FALSE;

                if (event.key.keysym.sym == SDLK_LEFT) {
                    --system_cursor;
                    if (system_cursor < 0) {
                        system_cursor = SDL_NUM_SYSTEM_CURSORS - 1;
                    }
                    updateCursor = SDL_TRUE;
                } else if (event.key.keysym.sym == SDLK_RIGHT) {
                    ++system_cursor;
                    if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) {
                        system_cursor = 0;
                    }
                    updateCursor = SDL_TRUE;
                }
                if (updateCursor) {
                    SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]);
                    SDL_FreeCursor(cursor);
                    cursor = SDL_CreateSystemCursor((SDL_SystemCursor)system_cursor);
                    SDL_SetCursor(cursor);
                }
            }
        }
#ifdef __EMSCRIPTEN__
    if (done) {
        emscripten_cancel_main_loop();
    }
#endif
}
Ejemplo n.º 9
0
void settingsScreen::load(screenManager* manager) {

	printf("The settings screen has loaded!\n");
	this->manager = manager;

	// Challenge puzzles button
	buttons.push_back(rectangle(5, 20, 90, 40));

	// Custom puzzles button
	buttons.push_back(rectangle(5, 80, 90, 40));

	// Settings button
	buttons.push_back(rectangle(5, 140, 90, 40));

	arrowCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
	pointerCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);

}
Ejemplo n.º 10
0
int Init () {
	if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
        return 1;
    }

	if ((window = SDL_CreateWindow("PID Demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_FULLSCREEN)) == NULL) {
		return 2;
	}

	if ((renderer = SDL_CreateRenderer(window, -1, 0)) == NULL) {
		return 3;
	}

	SDL_Surface* policeBMP;
	if ((policeBMP = SDL_LoadBMP("./police.bmp")) == NULL) {
		return 4;
	}

	if ((police = SDL_CreateTextureFromSurface(renderer, policeBMP)) == NULL) {
		return 5;
	}

	SDL_FreeSurface(policeBMP);

	SDL_Cursor* cursor;
	if ((cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR)) == NULL) {
		return 6;
	}

	SDL_SetCursor(cursor);

	policeDest.w = POLICE_WIDTH;
	policeDest.h = POLICE_HEIGHT;

	gains.p = 10;
	gains.i = 1;
	gains.d = 5;

	frameX.p = (SCREEN_WIDTH / 2) - (POLICE_WIDTH / 2);
	frameX.v = 0;
	frameX.a = 0;

	frameY.p = (SCREEN_HEIGHT / 2) - (POLICE_HEIGHT / 2);
	frameY.v = 0;
	frameY.a = 0;

	stateX.error = 0;
	stateX.integral = 0;

	stateY.error = 0;
	stateY.integral = 0;

	return 0;
}
Ejemplo n.º 11
0
    void Initialise()
    {
        Guard::Assert(!_initialised, "Cursors have already been initialised.");
        _initialised = true;

        // Using system cursors
        _loadedCursors[CURSOR_ARROW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
        _loadedCursors[CURSOR_HAND_POINT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);

        // Using custom cursors
        for (size_t i = 0; i < CURSOR_COUNT; i++)
        {
            const CursorData * cursorData = GetCursorData((CURSOR_ID)i);
            if (cursorData != nullptr)
            {
                _loadedCursors[i] = Create(cursorData);
            }
        }

        _currentCursor = CURSOR_UNDEFINED;
        SetCurrentCursor(CURSOR_ARROW);
    }
Ejemplo n.º 12
0
bool Cursor::createFromSystem(Type type)
{
    SDL_Cursor *created = SDL_CreateSystemCursor(type);
    if (!created)
    {
        Error() << "creating cursor from system: " << SDL_GetError();
    }
    else
    {
        load(created);
    }
    return created;
}
Ejemplo n.º 13
0
//------------------------------------------------------------------------------------------------------
//setter function that creates a system mouse cursor 
//------------------------------------------------------------------------------------------------------
void InputManager::SetMouseCursorType(CursorType cursorType)
{

	//first destroy old cursor object from memory
	SDL_FreeCursor(m_cursor);

	//based on type of cursor value passed, create mouse cursor using SDL ID flag value 
	m_cursor = SDL_CreateSystemCursor(SDL_SystemCursor(cursorType));
	
	//use cursor pointer to assign cursor to SDL
	SDL_SetCursor(m_cursor);

}
Ejemplo n.º 14
0
void break_computer_throw_cards_animation(void) {

  /** Computer throw cards animation end function. **/

  game_control->GAME_STATUS = CARDS_THROW ;
  game_control->SAVED_GAME_STATUS = CARDS_THROW ;
  game_control->is_animation_running = false ;

  game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
  SDL_SetCursor(game_control->cursor_type)  ;

  return ;
}
Ejemplo n.º 15
0
    InputDeviceSDL2::InputDeviceSDL2(OInput* pInput)
        : InputDevice(pInput)
    {
        m_mouseState[0] = 0;
        m_mouseState[1] = 1;
        m_mouseState[2] = 2;
        m_previousMouseState[0] = 0;
        m_previousMouseState[1] = 1;
        m_previousMouseState[2] = 2;

        SDL_Init(SDL_INIT_GAMECONTROLLER);

        m_pArrowCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
    }
Ejemplo n.º 16
0
void Cursor::ApplyOSCursorShape()
{
    // Mobile platforms do not support applying OS cursor shapes: comment out to avoid log error messages
#if !defined(ANDROID) && !defined(IOS)
    if (!osShapeDirty_ || !GetSubsystem<Input>()->IsMouseVisible() || GetSubsystem<SystemUI>()->GetCursor() != this)
        return;

    CursorShapeInfo& info = shapeInfos_[shape_];

    // Remove existing SDL cursor if is not a system shape while we should be using those, or vice versa
    if (info.osCursor_ && info.systemDefined_ != useSystemShapes_)
    {
        SDL_FreeCursor(info.osCursor_);
        info.osCursor_ = 0;
    }

    // Create SDL cursor now if necessary
    if (!info.osCursor_)
    {
        // Create a system default shape
        if (useSystemShapes_ && info.systemCursor_ >= 0 && info.systemCursor_ < CS_MAX_SHAPES)
        {
            info.osCursor_ = SDL_CreateSystemCursor((SDL_SystemCursor)osCursorLookup[info.systemCursor_]);
            info.systemDefined_ = true;
            if (!info.osCursor_)
                ATOMIC_LOGERROR("Could not create system cursor");
        }
        // Create from image
        else if (info.image_)
        {
            SDL_Surface* surface = info.image_->GetSDLSurface(info.imageRect_);

            if (surface)
            {
                info.osCursor_ = SDL_CreateColorCursor(surface, info.hotSpot_.x_, info.hotSpot_.y_);
                info.systemDefined_ = false;
                if (!info.osCursor_)
                    ATOMIC_LOGERROR("Could not create cursor from image " + info.image_->GetName());
                SDL_FreeSurface(surface);
            }
        }
    }

    if (info.osCursor_)
        SDL_SetCursor(info.osCursor_);

    osShapeDirty_ = false;
#endif
}
Ejemplo n.º 17
0
void Cursor::ApplyShape()
{
    CursorShapeInfo& info = shapeInfos_[shape_];
    texture_ = info.texture_;
    imageRect_ = info.imageRect_;
    SetSize(info.imageRect_.Size());

    // If the OS cursor is being shown, define/set SDL cursor shape if necessary
    // Only do this when we are the active UI cursor
    if (GetSubsystem<Input>()->IsMouseVisible() && GetSubsystem<UI>()->GetCursor() == this)
    {
        // Remove existing SDL cursor if is not a system shape while we should be using those, or vice versa
        if (info.osCursor_ && info.systemDefined_ != useSystemShapes_)
        {
            SDL_FreeCursor(info.osCursor_);
            info.osCursor_ = 0;
        }

        // Create SDL cursor now if necessary
        if (!info.osCursor_)
        {
            // Create a system default shape
            if (useSystemShapes_)
            {
                info.osCursor_ = SDL_CreateSystemCursor((SDL_SystemCursor)osCursorLookup[shape_]);
                info.systemDefined_ = true;
                if (!info.osCursor_)
                    LOGERROR("Could not create system cursor");
            }
            // Create from image
            else if (info.image_)
            {
                SDL_Surface* surface = info.image_->GetSDLSurface(info.imageRect_);
                
                if (surface)
                {
                    info.osCursor_ = SDL_CreateColorCursor(surface, info.hotSpot_.x_, info.hotSpot_.y_);
                    info.systemDefined_ = false;
                    if (!info.osCursor_)
                        LOGERROR("Could not create cursor from image " + info.image_->GetName());
                    SDL_FreeSurface(surface);
                }
            }
        }

        if (info.osCursor_)
            SDL_SetCursor(info.osCursor_);
    }
}
Ejemplo n.º 18
0
Cursor::Cursor(mouse::Cursor::SystemCursor cursortype)
	: cursor(nullptr)
	, type(CURSORTYPE_SYSTEM)
	, systemType(cursortype)
{
	SDL_SystemCursor sdlcursortype;

	if (systemCursors.find(cursortype, sdlcursortype))
		cursor = SDL_CreateSystemCursor(sdlcursortype);
	else
		throw love::Exception("Cannot create system cursor: invalid type.");

	if (!cursor)
		throw love::Exception("Cannot create system cursor: %s", SDL_GetError());
}
Ejemplo n.º 19
0
bool    ImGui_ImplSdlGL2_Init(SDL_Window* window)
{
    // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
    ImGuiIO& io = ImGui::GetIO();
    io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
    io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
    io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
    io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
    io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
    io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
    io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
    io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
    io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
    io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
    io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
    io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
    io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
    io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
    io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
    io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
    io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
    io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
    io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
    io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
    io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;

    io.SetClipboardTextFn = ImGui_ImplSdlGL2_SetClipboardText;
    io.GetClipboardTextFn = ImGui_ImplSdlGL2_GetClipboardText;
    io.ClipboardUserData = NULL;

    g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
    g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
    g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
    g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
    g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
    g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
    g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);

#ifdef _WIN32
    SDL_SysWMinfo wmInfo;
    SDL_VERSION(&wmInfo.version);
    SDL_GetWindowWMInfo(window, &wmInfo);
    io.ImeWindowHandle = wmInfo.info.win.window;
#else
    (void)window;
#endif

    return true;
}
Ejemplo n.º 20
0
	void sdl_window::set_mouse_cursor(mouse_system_cursor aSystemCursor)
	{
		SDL_SystemCursor sdlCursor = SDL_SYSTEM_CURSOR_ARROW;
		switch (aSystemCursor)
		{
		case mouse_system_cursor::Arrow:
			sdlCursor = SDL_SYSTEM_CURSOR_ARROW;
			break;
		case mouse_system_cursor::Ibeam:
			sdlCursor = SDL_SYSTEM_CURSOR_IBEAM;
			break;
		case mouse_system_cursor::Wait:
			sdlCursor = SDL_SYSTEM_CURSOR_WAIT;
			break;
		case mouse_system_cursor::Crosshair:
			sdlCursor = SDL_SYSTEM_CURSOR_CROSSHAIR;
			break;
		case mouse_system_cursor::WaitArrow:
			sdlCursor = SDL_SYSTEM_CURSOR_WAITARROW;
			break;
		case mouse_system_cursor::SizeNWSE:
			sdlCursor = SDL_SYSTEM_CURSOR_SIZENWSE;
			break;
		case mouse_system_cursor::SizeNESW:
			sdlCursor = SDL_SYSTEM_CURSOR_SIZENESW;
			break;
		case mouse_system_cursor::SizeWE:
			sdlCursor = SDL_SYSTEM_CURSOR_SIZEWE;
			break;
		case mouse_system_cursor::SizeNS:
			sdlCursor = SDL_SYSTEM_CURSOR_SIZENS;
			break;
		case mouse_system_cursor::SizeAll:
			sdlCursor = SDL_SYSTEM_CURSOR_SIZEALL;
			break;
		case mouse_system_cursor::No:
			sdlCursor = SDL_SYSTEM_CURSOR_NO;
			break;
		case mouse_system_cursor::Hand:
			sdlCursor = SDL_SYSTEM_CURSOR_HAND;
			break;
		}
		iCurrentCursor = cursor_pointer(cursor_pointer(), SDL_CreateSystemCursor(sdlCursor));
		SDL_SetCursor(&*iCurrentCursor);
	}
Ejemplo n.º 21
0
void BuyState::update(const float deltaTime)
{
#ifndef ANDROID_BUILD
	SDL_Point mousePosRunning;

	SDL_GetMouseState(&mousePosRunning.x, &mousePosRunning.y);
	SDL_Rect turretRect = getRect(turret_);

	if (!SDL_EnclosePoints(&mousePosRunning, 1, &turretRect, NULL))
	{
		SDL_Cursor* cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
		SDL_SetCursor(cursor);
		Game::getInstance().toPop_ = name();
	}
#else

#endif
}
Ejemplo n.º 22
0
void break_give_new_cards_animation(void) {

  if (! game_control->distribute && ! give_order) {
    give_order=true ;
    return ;
  }
  else if (game_control->distribute && give_order) {
    give_order=false ;
    return ;
  }


  game_control->GAME_STATUS = NEW_CARDS_GIVEN ;
  game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
  SDL_SetCursor(game_control->cursor_type)  ;
  game_control->is_animation_running = false ;

  return ;
}
Ejemplo n.º 23
0
void init_ui(bool fullscreen) {
    int width = 640, height = 480;
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
    screen = SDL_CreateWindow("putkijuoksu",
                          SDL_WINDOWPOS_UNDEFINED,
                          SDL_WINDOWPOS_UNDEFINED,
                          width, height,
                          (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0) |
                          SDL_WINDOW_OPENGL);
 
    if(screen == NULL)
        throw "could not init SDL / opengl";
    SDL_GetWindowSize(screen, &width, &height);
    SDL_GL_CreateContext(screen);
    SDL_SetRelativeMouseMode(SDL_TRUE);
    SDL_SetCursor(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW));

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(40, (double)width/(double)height, 0.1, 100);
    glMatrixMode(GL_MODELVIEW);
    glClearColor(0, 1, 1, 1);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glEnable(GL_MULTISAMPLE);

    glClearColor(0.5f,0.5f,0.5f,1.0f);
    glFogi(GL_FOG_MODE, GL_LINEAR);
    GLfloat fog_color[] = {0.5, 0.5, 0.5, 1};
    glFogfv(GL_FOG_COLOR, fog_color);
    glFogf(GL_FOG_DENSITY, 0.35f);
    glHint(GL_FOG_HINT, GL_DONT_CARE);
    glFogf(GL_FOG_START, VIEWDISTANCE-5);
    glFogf(GL_FOG_END, VIEWDISTANCE+5);
    glEnable(GL_FOG);
    init_resources();
}
Ejemplo n.º 24
0
Cursor::Cursor(CursorType cursorType) :
	m_cursorType(cursorType)
{
	FLAT_ASSERT(m_cursorType != INVALID_CURSOR);
	m_cursor = SDL_CreateSystemCursor(cursorType);
}
Ejemplo n.º 25
0
void get_events(int16_t *mouse_x, int16_t *mouse_y) {

  SDL_Event event;


  while (SDL_PollEvent(&event)) { /** Get user events. **/
    
  
  
    switch(event.type) {

      case SDL_QUIT:
	/** User press the cross to close the application. **/
	quit_game=true ;
	set_loop(false) ;
	break;

      case SDL_KEYDOWN :

	if (event.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
	  /** The user fallback to the previous screen. **/
	  set_loop(false) ;
	  break ;
	}

      case SDL_MOUSEMOTION :
     
       *mouse_x = event.motion.x ;  /** We keep the mouse position at everytime in the game. **/
       *mouse_y = event.motion.y ;  /** We keep the mouse position at everytime in the game. **/

     
     
	if ( ! game_control->is_animation_running && game_control->GAME_STATUS != DRAG_CARD_ON && game_control->GAME_STATUS != GAME_START ) {
	
	  if ( mouse_over_card(event.motion.x,event.motion.y) != -1 && ! game_control->is_animation_running ) {
	    /** The mouse is over an card. **/
	    if ( game_control->cursor_type != SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND) ) {
	      /** We set the cursor to an hand cursor to notify the user that he can return or drag-and-drop the card. **/
	      game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND) ;
	      SDL_SetCursor(game_control->cursor_type)  ;
	      game_control->mouse_over_card=true ;
	    }
	  
	  }
	  else {
	    if ( game_control->cursor_type != SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) && ! game_control->is_animation_running && ! is_mouse_in_buttons_bboxes(event.motion.x) ) {
	      /** We reset the cursor to default. **/
	      game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
	      SDL_SetCursor(game_control->cursor_type)  ;
	      game_control->mouse_over_card=false ;
	    }
	  }
	
       }
    
  
    
      if ( ! game_control->is_animation_running ) {
	/** The mouse is over an button. **/
	mouse_over_button(event.motion.x,event.motion.y) ;
	break ;
      }

    
    
      break ;
    
      case SDL_MOUSEBUTTONDOWN :

	if (event.button.button == SDL_BUTTON_LEFT && event.button.state == SDL_PRESSED) {
	
	  int8_t ret ;
	
	  if ( ! game_control->is_animation_running && ((ret=mouse_over_card(event.button.x,event.button.y)) != -1)  ) {
	    if (game_control->player[ret].is_back_faced) {
	      /** We process an card returning aniation. **/
	      current_card = &game_control->player[ret] ;
	      game_control->GAME_STATUS = RETURN_A_CARD ;
	      break ;
	    }
	    else if (! game_control->player[ret].is_back_faced && game_control->GAME_STATUS != DRAG_CARD_ON) {
	      /** The user can drag an card. **/	    
	      dragging_card->card = &game_control->player[ret] ;
	      dragging_card->x    =  event.button.x - game_control->player[ret].x  ;
	      dragging_card->y    =  event.button.y - game_control->player[ret].y  ;
	      	    
	      game_control->player[ret].is_moving = true ;
	    
	      game_control->GAME_STATUS = DRAG_CARD_ON ;
	    
	      game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL) ;
	      SDL_SetCursor(game_control->cursor_type)  ;
	    
	      break ;
	    }
	
	  }
	  else if ( ! game_control->is_animation_running && (ret = press_button(event.button.x,event.button.y)) != -1 ) {
	  
	    /** The user press an button which is allowed. **/
	  
	    do_change_game_status(ret) ;
	  
	    break ;
	  }
	  
	
      }
    
      case SDL_MOUSEBUTTONUP :

	if ( game_control->GAME_STATUS == DRAG_CARD_ON) {
	  /** The user release an card he is dragging, so we process. **/
	  game_control->GAME_STATUS = DRAG_CARD_OFF ;
	  game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
	  SDL_SetCursor(game_control->cursor_type)  ;
	}

	break ;

    }
  }

  return ;
}
Ejemplo n.º 26
0
int
main(int argc, char *argv[])
{
    int i;
    const char *color_cursor = NULL;

    /* Enable standard application logging */
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

    /* Initialize test framework */
    state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
    if (!state) {
        return 1;
    }
    for (i = 1; i < argc;) {
        int consumed;

        consumed = SDLTest_CommonArg(state, i);
        if (consumed == 0) {
            color_cursor = argv[i];
            break;
        }
        if (consumed < 0) {
            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
            quit(1);
        }
        i += consumed;
    }

    if (!SDLTest_CommonInit(state)) {
        quit(2);
    }

    for (i = 0; i < state->num_windows; ++i) {
        SDL_Renderer *renderer = state->renderers[i];
        SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
        SDL_RenderClear(renderer);
    }

    if (color_cursor) {
        cursors[0] = init_color_cursor(color_cursor);
    } else {
        cursors[0] = init_system_cursor(arrow);
    }
    if (!cursors[0]) {
        SDL_Log("Error, couldn't create cursor\n");
        quit(2);
    }
    for (i = 0; i < SDL_NUM_SYSTEM_CURSORS; ++i) {
        cursors[1+i] = SDL_CreateSystemCursor((SDL_SystemCursor)i);
        if (!cursors[1+i]) {
            SDL_Log("Error, couldn't create system cursor %d\n", i);
            quit(2);
        }
    }
    SDL_SetCursor(cursors[0]);

    /* Main render loop */
    done = 0;
#ifdef __EMSCRIPTEN__
    emscripten_set_main_loop(loop, 0, 1);
#else
    while (!done) {
        loop();
    }
#endif

    for (i = 0; i < SDL_arraysize(cursors); ++i) {
        SDL_FreeCursor(cursors[i]);
    }
    quit(0);

    /* keep the compiler happy ... */
    return(0);
}
Ejemplo n.º 27
0
void gathering_cards_animation(SDL_Renderer *pRenderer,SDL_Texture *card_back_face_texture,Vector distribute_cards[10][50],Anim_Cards *anim_cards_settings, int *sleep, _Bool invert) {

  /** Gathering cards animation.
   *  The function need a Anim_Cards structure to control the animation.
   *  Each vector represent the current card postion.
   *  For each card their an Vector array from size depending from the length of the travel to reach the throw card frame.
   *  ********************************************************************************************************************/

  if (game_control->GAME_STATUS == CLEAN_PLAYGROUND) {
      if ((anim_cards_settings->step == 0) && (anim_cards_settings->card == 0)) {

        /** First time this function is called:
          *  So we initialize the setting for an animation.
          *************************************************/

        *sleep=5250 ;  /** We set the pausing time from the mainloop. **/

        game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW) ;
        SDL_SetCursor(game_control->cursor_type)  ;
        game_control->is_animation_running = true ;

        if (! invert) {
          /** Case we gather the player card first. **/
          game_control->player[0].card_is_throw   = true ;
        }
        else {
          /** Case we gather the computer card first. **/
          game_control->computer[0].card_is_throw = true ;
        }
      }
  
      anim_cards_settings->step++ ;
  
      display_a_card_by_animation(pRenderer,card_back_face_texture ,distribute_cards[anim_cards_settings->card][anim_cards_settings->step]) ;
  
  
      if ((anim_cards_settings->step == 50) && (anim_cards_settings->card == 0 )) {

        /** The first card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        if (! bounding_boxes[5].is_frame_empty) {

          /** Case the throw card heap was empty before. **/

          bounding_boxes[5].is_frame_empty=false ;
        }

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->pos_to_fill++  ;
        anim_cards_settings->cards_number++ ;

        if (! invert) {
          /** Case we gather the player card. **/
          game_control->computer[0].card_is_throw = true ;
        }
        else {
          /** Case we gather the computer card. **/
          game_control->player[0].card_is_throw   = true ;
        }

      }
     else if ((anim_cards_settings->step == 50) && (anim_cards_settings->card == 1)) {
   
       /** The first card has reach the throw card frame.
         * Even from the player or the computer hand first
         * depending from the value from the boolean variable invert. **/
   
       anim_cards_settings->card++ ;
       anim_cards_settings->step=0 ;
   
       *sleep=6375 ;  /** We set the pausing time from the mainloop. **/
   
       anim_cards_settings->cards_number++ ;

       if (! invert) {
         /** Case we gather the player card. **/
         game_control->player[1].card_is_throw   = true ;
      }
      else {
        /** Case we gather the computer card. **/
        game_control->computer[1].card_is_throw = true ;
      }

      }
      else if ((anim_cards_settings->step == 40) && (anim_cards_settings->card == 2 )) {

        /** The second card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->pos_to_fill++  ;
        anim_cards_settings->cards_number++ ;

        if (! invert) {
          /** Case we gather the player card first. **/
          game_control->computer[1].card_is_throw = true ;
        }
        else {
          /** Case we gather the computer card first. **/
          game_control->player[1].card_is_throw   = true ;
        }

      }
      else if ((anim_cards_settings->step == 40) && (anim_cards_settings->card == 3)) {

        /** The second card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        *sleep=7500 ;  /** We set the pausing time from the mainloop. **/

        anim_cards_settings->cards_number++ ;

        if (! invert) {
          /** Case we gather the player card. **/
          game_control->player[2].card_is_throw   = true ;
        }
        else {
          /** Case we gather the computer card. **/
          game_control->computer[2].card_is_throw = true ;
        }

      }
      else if ((anim_cards_settings->step == 30) && (anim_cards_settings->card == 4)) {

        /** The third card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->cards_number++ ;
        anim_cards_settings->pos_to_fill++  ;

        if (! invert) {
          /** Case we gather the player card. **/
          game_control->computer[2].card_is_throw = true ;
        }
        else {
          /** Case we gather the computer card. **/
          game_control->player[2].card_is_throw   = true ;
        }

      }
      else if ((anim_cards_settings->step == 30) && (anim_cards_settings->card == 5)) {

        /** The third card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        *sleep=10000 ;  /** We set the pausing time from the mainloop. **/

        anim_cards_settings->cards_number++ ;

        if (! invert) {
          /** Case we gather the player card. **/
          game_control->player[3].card_is_throw   = true ;
        }
        else {
          /** Case we gather the computer card. **/
          game_control->computer[3].card_is_throw = true ;
        }

      }
      else if ((anim_cards_settings->step == 20) && (anim_cards_settings->card == 6 )) {

        /** The fourth card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->cards_number++ ;
        anim_cards_settings->pos_to_fill++  ;

        if (! invert) {
          /** Case we gather the player card. **/
          game_control->computer[3].card_is_throw = true ;
        }
        else {
          /** Case we gather the computer card. **/
          game_control->player[3].card_is_throw   = true ;
        }

      }
      else if ((anim_cards_settings->step == 20) && (anim_cards_settings->card == 7 )) {

        /** The fourth card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        *sleep=12500 ;  /** We set the pausing time from the mainloop. **/

        anim_cards_settings->cards_number++ ;

        if (! invert) {
          /** Case we gather the player card. **/
          game_control->player[4].card_is_throw   = true ;
        }
        else {
          /** Case we gather the computer card. **/
          game_control->computer[4].card_is_throw = true ;
        }

      }
      else if ((anim_cards_settings->step == 10) && (anim_cards_settings->card == 8)) {

        /** The fives card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->cards_number++ ;
        anim_cards_settings->pos_to_fill++  ;

        if (! invert) {
          /** Case we gather the player card. **/
          game_control->computer[4].card_is_throw = true ;
        }
        else {
          /** Case we gather the computer card. **/
          game_control->player[4].card_is_throw   = true ;
        }

      }
      else if ((anim_cards_settings->step == 10) && (anim_cards_settings->card == 9)) {

        /** The fives card has reach the throw card frame.
         *  Even from the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/


        /** The animation is finish we process the settings. **/
        game_control->GAME_STATUS=PLAYGROUND_CLEAN ;

        anim_cards_settings->card=0 ;
        anim_cards_settings->step=0 ;

        *sleep=10000 ; /** We reset the pausing time from the mainloop on the default value. **/

        anim_cards_settings->cards_number++ ;
      }
  

  }


  display_throw_cards(pRenderer,card_back_face_texture) ;

  return ;
}
Ejemplo n.º 28
0
/**
 *rct2: 0x0068352C
 */
static void osinterface_load_cursors(){

	RCT2_GLOBAL(0x14241BC, uint32) = 2;
	HINSTANCE hInst = RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE);
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_ARROW,				HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x74));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_BLANK,				HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA1));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_UP_ARROW,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x6D));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_UP_DOWN_ARROW,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x6E));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_HAND_POINT,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x70));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_ZZZ,				HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x78));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_DIAGONAL_ARROWS,	HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x77));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_PICKER,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x7C));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_TREE_DOWN,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x83));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_FOUNTAIN_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x7F));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_STATUE_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x80));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_BENCH_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x81));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_CROSS_HAIR,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x82));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_BIN_DOWN,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x84));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_LAMPPOST_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x85));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_FENCE_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x8A));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_FLOWER_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x89));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_PATH_DOWN,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x8B));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_DIG_DOWN,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x8D));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_WATER_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x8E));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_HOUSE_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x8F));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_VOLCANO_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x90));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_WALK_DOWN,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x91));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_PAINT_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x9E));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_ENTRANCE_DOWN,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x9F));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_HAND_OPEN,			HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA6));
	RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_HAND_CLOSED,		HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA5));

	_cursors[0] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
	_cursors[1] = SDL_CreateCursor(blank_cursor_data, blank_cursor_mask, 32, 32, BLANK_CURSOR_HOTX, BLANK_CURSOR_HOTY);
	_cursors[2] = SDL_CreateCursor(up_arrow_cursor_data, up_arrow_cursor_mask, 32, 32, UP_ARROW_CURSOR_HOTX, UP_ARROW_CURSOR_HOTY);
	_cursors[3] = SDL_CreateCursor(up_down_arrow_cursor_data, up_down_arrow_cursor_mask, 32, 32, UP_DOWN_ARROW_CURSOR_HOTX, UP_DOWN_ARROW_CURSOR_HOTY);
	_cursors[4] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
	_cursors[5] = SDL_CreateCursor(zzz_cursor_data, zzz_cursor_mask, 32, 32, ZZZ_CURSOR_HOTX, ZZZ_CURSOR_HOTY);
	_cursors[6] = SDL_CreateCursor(diagonal_arrow_cursor_data, diagonal_arrow_cursor_mask, 32, 32, DIAGONAL_ARROW_CURSOR_HOTX, DIAGONAL_ARROW_CURSOR_HOTY);
	_cursors[7] = SDL_CreateCursor(picker_cursor_data, picker_cursor_mask, 32, 32, PICKER_CURSOR_HOTX, PICKER_CURSOR_HOTY);
	_cursors[8] = SDL_CreateCursor(tree_down_cursor_data, tree_down_cursor_mask, 32, 32, TREE_DOWN_CURSOR_HOTX, TREE_DOWN_CURSOR_HOTY);
	_cursors[9] = SDL_CreateCursor(fountain_down_cursor_data, fountain_down_cursor_mask, 32, 32, FOUNTAIN_DOWN_CURSOR_HOTX, FOUNTAIN_DOWN_CURSOR_HOTY);
	_cursors[10] = SDL_CreateCursor(statue_down_cursor_data, statue_down_cursor_mask, 32, 32, STATUE_DOWN_CURSOR_HOTX, STATUE_DOWN_CURSOR_HOTY);
	_cursors[11] = SDL_CreateCursor(bench_down_cursor_data, bench_down_cursor_mask, 32, 32, BENCH_DOWN_CURSOR_HOTX, BENCH_DOWN_CURSOR_HOTY);
	_cursors[12] = SDL_CreateCursor(cross_hair_cursor_data, cross_hair_cursor_mask, 32, 32, CROSS_HAIR_CURSOR_HOTX, CROSS_HAIR_CURSOR_HOTY);
	_cursors[13] = SDL_CreateCursor(bin_down_cursor_data, bin_down_cursor_mask, 32, 32, BIN_DOWN_CURSOR_HOTX, BIN_DOWN_CURSOR_HOTY);
	_cursors[14] = SDL_CreateCursor(lamppost_down_cursor_data, lamppost_down_cursor_mask, 32, 32, LAMPPOST_DOWN_CURSOR_HOTX, LAMPPOST_DOWN_CURSOR_HOTY);
	_cursors[15] = SDL_CreateCursor(fence_down_cursor_data, fence_down_cursor_mask, 32, 32, FENCE_DOWN_CURSOR_HOTX, FENCE_DOWN_CURSOR_HOTY);
	_cursors[16] = SDL_CreateCursor(flower_down_cursor_data, flower_down_cursor_mask, 32, 32, FLOWER_DOWN_CURSOR_HOTX, FLOWER_DOWN_CURSOR_HOTY);
	_cursors[17] = SDL_CreateCursor(path_down_cursor_data, path_down_cursor_mask, 32, 32, PATH_DOWN_CURSOR_HOTX, PATH_DOWN_CURSOR_HOTY);
	_cursors[18] = SDL_CreateCursor(dig_down_cursor_data, dig_down_cursor_mask, 32, 32, DIG_DOWN_CURSOR_HOTX, DIG_DOWN_CURSOR_HOTY);
	_cursors[19] = SDL_CreateCursor(water_down_cursor_data, water_down_cursor_mask, 32, 32, WATER_DOWN_CURSOR_HOTX, WATER_DOWN_CURSOR_HOTY);
	_cursors[20] = SDL_CreateCursor(house_down_cursor_data, house_down_cursor_mask, 32, 32, HOUSE_DOWN_CURSOR_HOTX, HOUSE_DOWN_CURSOR_HOTY);
	_cursors[21] = SDL_CreateCursor(volcano_down_cursor_data, volcano_down_cursor_mask, 32, 32, VOLCANO_DOWN_CURSOR_HOTX, VOLCANO_DOWN_CURSOR_HOTY);
	_cursors[22] = SDL_CreateCursor(walk_down_cursor_data, walk_down_cursor_mask, 32, 32, WALK_DOWN_CURSOR_HOTX, WALK_DOWN_CURSOR_HOTY);
	_cursors[23] = SDL_CreateCursor(paint_down_cursor_data, paint_down_cursor_mask, 32, 32, PAINT_DOWN_CURSOR_HOTX, PAINT_DOWN_CURSOR_HOTY);
	_cursors[24] = SDL_CreateCursor(entrance_down_cursor_data, entrance_down_cursor_mask, 32, 32, ENTRANCE_DOWN_CURSOR_HOTX, ENTRANCE_DOWN_CURSOR_HOTY);
	_cursors[25] = SDL_CreateCursor(hand_open_cursor_data, hand_open_cursor_mask, 32, 32, HAND_OPEN_CURSOR_HOTX, HAND_OPEN_CURSOR_HOTY);
	_cursors[26] = SDL_CreateCursor(hand_closed_cursor_data, hand_closed_cursor_mask, 32, 32, HAND_CLOSED_CURSOR_HOTX, HAND_CLOSED_CURSOR_HOTY);
	osinterface_set_cursor(CURSOR_ARROW);
	RCT2_GLOBAL(0x14241BC, uint32) = 0;
}
Ejemplo n.º 29
0
void distribute_cards(SDL_Renderer *pRenderer,SDL_Texture *card_back_face_texture,Vector distribute_cards[10][50],Anim_Cards *anim_cards_settings, int *sleep, _Bool invert) {

  /** Distribute cards animation.
   *  The function need a Anim_Cards structure to control the animation.
   *  Each vector represent the current card postion.
   *  For each card their an Vector array from size depending from the length of the travel to reach the throw card frame.
   *  ********************************************************************************************************************/

  if (game_control->GAME_STATUS == CARDS_DISTRIBUTE) {
      if ((anim_cards_settings->step == 0) && (anim_cards_settings->card == 0)) {

        /** First time this function is called:
          *  So we initialize the setting for an animation.
          *************************************************/

        *sleep=12500 ;
        game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW) ;
        SDL_SetCursor(game_control->cursor_type)  ;
        game_control->is_animation_running = true ;

      }
  
      /** Display the current card to throw during the animation. **/
      display_a_card_by_animation(pRenderer,card_back_face_texture ,distribute_cards[anim_cards_settings->card][anim_cards_settings->step]) ;
  
      anim_cards_settings->step++ ;
  
      if ((anim_cards_settings->step == 10) && (anim_cards_settings->card == 0 )) {

        /** The first card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->pos_to_fill++  ;
        anim_cards_settings->cards_number++ ;
      }
     else if ((anim_cards_settings->step == 10) && (anim_cards_settings->card == 1)) {
       /** The first card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/
   
       anim_cards_settings->card++ ;
       anim_cards_settings->step=0 ;
   
       /** The first card is distribute for the player and the computer
        *  so we set the sleep value for the next card animation.       */
       *sleep -= 2500  ;
   
       anim_cards_settings->cards_number++ ;

      }
      else if ((anim_cards_settings->step == 20) && (anim_cards_settings->card == 2 )) {
        /** The second card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->pos_to_fill++  ;
        anim_cards_settings->cards_number++ ;
      }
      else if ((anim_cards_settings->step == 20) && (anim_cards_settings->card == 3)) {
        /** The second card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        /** The second card is distribute for the player and the computer
         *  so we set the sleep value for the next card animation.         */
        *sleep -= 2500  ;

        anim_cards_settings->cards_number++ ;
      }
      else if ((anim_cards_settings->step == 30) && (anim_cards_settings->card == 4)) {
        /** The third card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->cards_number++ ;
        anim_cards_settings->pos_to_fill++  ;
      }
      else if ((anim_cards_settings->step == 30) && (anim_cards_settings->card == 5)) {
        /** The third card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        /** The third card is distribute for the player and the computer
         *  so we set the sleep value for the next card animation.         */
        *sleep -= 1125 ;

        anim_cards_settings->cards_number++ ;
      }
      else if ((anim_cards_settings->step == 40) && (anim_cards_settings->card == 6 )) {
        /** The fourth card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->cards_number++ ;
        anim_cards_settings->pos_to_fill++  ;
      }
      else if ((anim_cards_settings->step == 40) && (anim_cards_settings->card == 7 )) {
        /** The fourth card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        /** The fourth card is distribute for the player and the computer
         *  so we set the sleep value for the next card animation.         */
        *sleep -= 1125 ;
        anim_cards_settings->cards_number++ ;
      }
      else if ((anim_cards_settings->step == 50) && (anim_cards_settings->card == 8)) {
        /** The fives card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        anim_cards_settings->card++ ;
        anim_cards_settings->step=0 ;

        anim_cards_settings->cards_number++ ;
        anim_cards_settings->pos_to_fill++  ;
      }
      else if ((anim_cards_settings->step == 50) && (anim_cards_settings->card == 9)) {
        /** The fives card has reach his destination, even the player or the computer hand first
         *  depending from the value from the boolean variable invert. **/

        /** The anilation has reach his end we reset the settings to play. **/
        game_control->GAME_STATUS=CARDS_COVER ;
        anim_cards_settings->card=0 ;
        anim_cards_settings->step=0 ;
        *sleep=10000 ;
        anim_cards_settings->cards_number++ ;
        game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
        SDL_SetCursor(game_control->cursor_type)  ;
        game_control->is_animation_running = false ;
      }
  

  }

  if ( game_control->GAME_STATUS == CARDS_DISTRIBUTE ) {
    /** Display the cards in relationship to which has reach the destination. **/
    display_back_face_card(pRenderer,card_back_face_texture, anim_cards_settings->pos_to_fill, anim_cards_settings->cards_number, invert) ;
  }
  else if (game_control->GAME_STATUS == CARDS_COVER ) {
    /** Display all cards returned **/
    display_back_face_card(pRenderer,card_back_face_texture, 5, 10, invert) ;
    anim_cards_settings->cards_number=0 ;
    anim_cards_settings->pos_to_fill=0  ;
  }

  return ;
}
Ejemplo n.º 30
0
void Mouse::setCursor( const MouseCursor cursor )
{
    SDL_SystemCursor cursorName(SDL_SYSTEM_CURSOR_ARROW);
    switch(cursor)
    {
        case io::MouseCursor_Progress:
            cursorName = SDL_SYSTEM_CURSOR_WAIT; break;
            
        case io::MouseCursor_Custom:
        case io::MouseCursor_ZoomIn:
        case io::MouseCursor_ZoomOut:
        case io::MouseCursor_Pointer:
        case io::MouseCursor_Copy:
        case io::MouseCursor_None:
        case io::MouseCursor_VerticalText:
        case io::MouseCursor_Cell:
        case io::MouseCursor_ContextMenu:
        case io::MouseCursor_Alias:
            cursorName = SDL_SYSTEM_CURSOR_ARROW; break;
            
        case io::MouseCursor_Cross:
            cursorName = SDL_SYSTEM_CURSOR_CROSSHAIR; break;
            
        case io::MouseCursor_Grab:
        case io::MouseCursor_Grabbing:
        case io::MouseCursor_Hand:
            cursorName = SDL_SYSTEM_CURSOR_HAND; break;
            
        case io::MouseCursor_Help:
            cursorName = SDL_SYSTEM_CURSOR_ARROW; break;
            
        case io::MouseCursor_IBeam:
            cursorName = SDL_SYSTEM_CURSOR_IBEAM; break;
            
        case io::MouseCursor_NoDrop:
        case io::MouseCursor_NotAllowed:
            cursorName = SDL_SYSTEM_CURSOR_NO; break;
            
        case io::MouseCursor_Move:
        case io::MouseCursor_MiddlePanning:
        case io::MouseCursor_EastPanning:
        case io::MouseCursor_WestPanning:
        case io::MouseCursor_NorthPanning:
        case io::MouseCursor_SouthPanning:
        case io::MouseCursor_NorthEastPanning:
        case io::MouseCursor_SouthWestPanning:
        case io::MouseCursor_NorthWestPanning:
        case io::MouseCursor_SouthEastPanning:
            cursorName = SDL_SYSTEM_CURSOR_SIZEALL; break;
            
        case io::MouseCursor_NorthEastSouthWestResize:
        case io::MouseCursor_NorthEastResize:
        case io::MouseCursor_SouthWestResize:
            cursorName = SDL_SYSTEM_CURSOR_SIZENESW; break;
            
        case io::MouseCursor_NorthSouthResize:
        case io::MouseCursor_NorthResize:
        case io::MouseCursor_RowResize:
        case io::MouseCursor_SouthResize:
            cursorName = SDL_SYSTEM_CURSOR_SIZENS; break;
            
        case io::MouseCursor_NorthWestResize:
        case io::MouseCursor_NorthWestSouthEastResize:
        case io::MouseCursor_SouthEastResize:
            cursorName = SDL_SYSTEM_CURSOR_SIZENWSE; break;
            
        case io::MouseCursor_EastWestResize:
        case io::MouseCursor_EastResize:
        case io::MouseCursor_ColumnResize:
        case io::MouseCursor_WestResize:
            cursorName = SDL_SYSTEM_CURSOR_SIZEWE; break;
            
        case io::MouseCursor_Wait:
            cursorName = SDL_SYSTEM_CURSOR_WAITARROW; break;
        default:
            LOG(LogType_ProgrammerAssert, "Unknow mouse cursor %d", cursor);
    }
    
    SDL_Cursor* oldCursor(m_Cursor);
    m_Cursor = SDL_CreateSystemCursor(cursorName);
    SDL_SetCursor(m_Cursor);
    if (oldCursor != nullptr)
        SDL_FreeCursor(oldCursor);
}