hedgewars/uMobile.pas
author koda
Wed, 04 May 2011 01:19:39 +0200
changeset 5201 7b9aa7aac336
parent 5180 a881cd3d3163
child 5994 3c578f531cc1
permissions -rw-r--r--
* moved colours and default port from .cpp.in to .h * slight tweaks to existing colours (softer shades)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     1
(*
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4948
diff changeset
     3
 * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     4
 *
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     8
 *
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    13
 *
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    17
 *)
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    18
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    19
{$INCLUDE "options.inc"}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    20
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    21
unit uMobile;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    22
interface
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    23
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    24
{$IFDEF IPHONEOS}
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 3952
diff changeset
    25
(*  iOS calls written in ObjcExports.m  *)
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    26
procedure clearView; cdecl; external;
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    27
procedure startSpinningProgress; cdecl; external;
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    28
procedure stopSpinningProgress; cdecl; external;
5180
a881cd3d3163 small cosmetics
koda
parents: 5178
diff changeset
    29
procedure saveBeganSynching; cdecl; external;
a881cd3d3163 small cosmetics
koda
parents: 5178
diff changeset
    30
procedure saveFinishedSynching; cdecl; external;
4861
91f889289a47 (ios) perform a small change about how to close the game window, should hopefully save memory and avoid crashes (who am i kidding? that's the usual PR talk...)
koda
parents: 4507
diff changeset
    31
procedure setGameRunning(arg: boolean); cdecl; external;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    32
procedure updateVisualsNewTurn; cdecl; external;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    33
function  isApplePhone: Boolean; cdecl; external;
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 3952
diff changeset
    34
procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    35
{$ENDIF}
3948
24daa33a3114 some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents: 3940
diff changeset
    36
function  isPhone: Boolean; inline;
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 3952
diff changeset
    37
procedure performRumble; inline;
5167
7b515d0945b1 Clean Augean stables 2 (pascal has classnames available)
koda
parents: 4976
diff changeset
    38
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    39
procedure GameLoading; inline;
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    40
procedure GameLoaded; inline;
5167
7b515d0945b1 Clean Augean stables 2 (pascal has classnames available)
koda
parents: 4976
diff changeset
    41
procedure AmmoUpdate; // don't inline
7b515d0945b1 Clean Augean stables 2 (pascal has classnames available)
koda
parents: 4976
diff changeset
    42
procedure NewTurnBeginning; inline;
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    43
procedure SaveBegan; inline;
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    44
procedure SaveFinished; inline;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    45
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    46
implementation
4437
05192cdbce9b un-break build (wrong merge in uConsole) and update project file with the new sources
koda
parents: 4436
diff changeset
    47
uses uVariables;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    48
3948
24daa33a3114 some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents: 3940
diff changeset
    49
function isPhone: Boolean; inline;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    50
begin
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    51
{$IFDEF IPHONEOS}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    52
    exit(isApplePhone());
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    53
{$ENDIF}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    54
    exit(false);
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    55
end;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    56
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 3952
diff changeset
    57
procedure performRumble; inline;
5168
8a074a255af0 small tweak to autogenerate the config.inc file in the ios project
koda
parents: 5167
diff changeset
    58
const kSystemSoundID_Vibrate = $00000FFF;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    59
begin
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 3952
diff changeset
    60
{$IFDEF IPHONEOS}
4948
c3dc41ae68fa remove unused ios code
koda
parents: 4861
diff changeset
    61
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 3952
diff changeset
    62
{$ENDIF}
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    63
end;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    64
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    65
procedure GameLoading; inline;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    66
begin
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    67
{$IFDEF IPHONEOS}
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    68
    startSpinningProgress();
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    69
{$ENDIF}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    70
end;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    71
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    72
procedure GameLoaded; inline;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    73
begin
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    74
{$IFDEF IPHONEOS}
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    75
    stopSpinningProgress();
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    76
{$ENDIF}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    77
end;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    78
5167
7b515d0945b1 Clean Augean stables 2 (pascal has classnames available)
koda
parents: 4976
diff changeset
    79
procedure AmmoUpdate; // don't inline
3935
5ca27a0e9a63 made the new menu toggable
koda
parents: 3928
diff changeset
    80
begin
5ca27a0e9a63 made the new menu toggable
koda
parents: 3928
diff changeset
    81
{$IFDEF IPHONEOS}
4362
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    82
    if (CurrentTeam = nil) or
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    83
       (CurrentTeam^.ExtDriven) or
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    84
       (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then
3940
cc29628976cc some optimizations to drawing and fetching data of new ammomenu
koda
parents: 3935
diff changeset
    85
        exit(); // the other way around throws a compiler error
3935
5ca27a0e9a63 made the new menu toggable
koda
parents: 3928
diff changeset
    86
    updateVisualsNewTurn();
5ca27a0e9a63 made the new menu toggable
koda
parents: 3928
diff changeset
    87
{$ENDIF}
5ca27a0e9a63 made the new menu toggable
koda
parents: 3928
diff changeset
    88
end;
5ca27a0e9a63 made the new menu toggable
koda
parents: 3928
diff changeset
    89
5167
7b515d0945b1 Clean Augean stables 2 (pascal has classnames available)
koda
parents: 4976
diff changeset
    90
procedure NewTurnBeginning; inline;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    91
begin
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    92
{$IFDEF IPHONEOS}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    93
    clearView();
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    94
{$ENDIF}
5167
7b515d0945b1 Clean Augean stables 2 (pascal has classnames available)
koda
parents: 4976
diff changeset
    95
    AmmoUpdate();
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    96
end;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    97
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
    98
procedure SaveBegan; inline;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
    99
begin
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   100
{$IFDEF IPHONEOS}
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
   101
    saveBeganSynching();
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   102
{$ENDIF}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   103
end;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   104
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
   105
procedure SaveFinished; inline;
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   106
begin
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   107
{$IFDEF IPHONEOS}
5174
f5294509783e initial refactoring of ObjcExports and OverlayViewController
koda
parents: 5168
diff changeset
   108
    saveFinishedSynching();
3928
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   109
{$ENDIF}
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   110
end;
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   111
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   112
2560731c860d move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff changeset
   113
end.