hedgewars/uCursor.pas
author Xeli
Sat, 04 Feb 2012 16:22:46 +0100
changeset 6622 01889d5bc79b
parent 6580 6155187bf599
child 8026 4a4f21070479
child 8222 d3dc08500fc0
permissions -rw-r--r--
Rewrote the Ammomenu: Added landscape ammomenu At the moment MOBILE indicates landscape, but we could just as easily make a variable out of it Draw to texture once uVariables.AmmoMenuInvalidated indicates a new ammo menu needs to be drawn, see uTeams and uAmmos Slot/Cellsize is dependent on uConsts.AMSlotSize this should make it easier to scale the ammo menu on smaller screens AmmoRect AmmoRect indicates where and how big the ammo menu is, this makes positioning a bit easier imo, because you only need to change the position at one single point needs testing on the iphone (and other systems as well ofcourse..)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5191
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     1
unit uCursor;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     2
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     3
interface
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     4
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     5
procedure init;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     6
procedure updatePosition;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     7
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     8
implementation
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     9
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    10
uses SDLh, uVariables;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    11
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    12
procedure init;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    13
begin
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    14
    SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    15
end;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    16
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    17
procedure updatePosition;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    18
var x, y: LongInt;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    19
begin
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    20
    SDL_GetMouseState(@x, @y);
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    21
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    22
    if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    23
        begin
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    24
        CursorPoint.X:= CursorPoint.X + x - cScreenWidth div 2;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    25
        CursorPoint.Y:= CursorPoint.Y - y + cScreenHeight div 2;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    26
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 5199
diff changeset
    27
        if cHasFocus then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 5199
diff changeset
    28
            SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
5191
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    29
        end
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    30
end;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    31
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    32
end.