First bits of oolite-gui based load/save commander UI
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@83 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
002459fd10
commit
4550ca7361
@ -8,7 +8,7 @@ APP_NAME = oolite
|
||||
oolite_LIB_DIRS += -L/usr/X11R6/lib/
|
||||
|
||||
oolite_C_FILES = vector.c legacy_random.c
|
||||
oolite_OBJC_FILES = Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntity_Additions.m PlayerEntity_contracts.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntity_AI.m ShipEntity.m SkyEntity.m StationEntity.m TextureStore.m Universe.m OOSound.m OOMusic.m SDLImage.m
|
||||
oolite_OBJC_FILES = Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntity_Additions.m PlayerEntity_contracts.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntity_AI.m ShipEntity.m SkyEntity.m StationEntity.m TextureStore.m Universe.m OOSound.m OOMusic.m SDLImage.m LoadSave.m
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/application.make
|
||||
include GNUmakefile.postamble
|
||||
|
34
LoadSave.h
Normal file
34
LoadSave.h
Normal file
@ -0,0 +1,34 @@
|
||||
//
|
||||
// LoadSave.h
|
||||
//
|
||||
// Created for the Oolite-Linux project (but is portable)
|
||||
//
|
||||
// Dylan Smith, 2005-06-21
|
||||
//
|
||||
// LoadSave has been separated out into a separate category because
|
||||
// PlayerEntity.m has gotten far too big and is in danger of becoming
|
||||
// the whole general mish mash.
|
||||
//
|
||||
// oolite: (c) 2004 Giles C Williams.
|
||||
// This work is licensed under the Creative Commons Attribution NonCommercial
|
||||
// ShareAlike license.
|
||||
//
|
||||
#import "PlayerEntity.h"
|
||||
#import "GuiDisplayGen.h"
|
||||
#import "MyOpenGLView.h"
|
||||
#import "Universe.h"
|
||||
|
||||
#define STARTROW 2
|
||||
#define ENDROW 20
|
||||
#define COLUMNS 2
|
||||
|
||||
@interface PlayerEntity (LoadSave)
|
||||
|
||||
- (void) setGuiToLoadCommanderScreen;
|
||||
- (void) setGuiToSaveCommanderScreen;
|
||||
- (void) lsCommanders: (GuiDisplayGen *)gui;
|
||||
- (void) commanderSelector: (GuiDisplayGen *)gui
|
||||
: (MyOpenGLView *)gameView;
|
||||
|
||||
@end
|
||||
|
66
LoadSave.m
Normal file
66
LoadSave.m
Normal file
@ -0,0 +1,66 @@
|
||||
//
|
||||
// LoadSave.m
|
||||
//
|
||||
// Created for the Oolite-Linux project (but is portable)
|
||||
//
|
||||
// Dylan Smith, 2005-06-21
|
||||
//
|
||||
// LoadSave has been separated out into a separate category because
|
||||
// PlayerEntity.m has gotten far too big and is in danger of becoming
|
||||
// the whole general mish mash.
|
||||
//
|
||||
// oolite: (c) 2004 Giles C Williams.
|
||||
// This work is licensed under the Creative Commons Attribution NonCommercial
|
||||
// ShareAlike license.
|
||||
//
|
||||
|
||||
#import "LoadSave.h"
|
||||
|
||||
@implementation PlayerEntity (LoadSave)
|
||||
|
||||
- (void) setGuiToLoadCommanderScreen
|
||||
{
|
||||
GameController *controller=[universe gameController];
|
||||
GuiDisplayGen *gui=[universe gui];
|
||||
|
||||
gui_screen = GUI_SCREEN_LOAD;
|
||||
|
||||
[gui clear];
|
||||
[gui setTitle:[NSString stringWithFormat:@"Select Commander"]];
|
||||
|
||||
[self lsCommanders: gui];
|
||||
[gui setSelectedRow: STARTROW];
|
||||
[universe guiUpdated];
|
||||
}
|
||||
|
||||
- (void) setGuiToSaveCommanderScreen
|
||||
{
|
||||
}
|
||||
|
||||
- (void) lsCommanders: (GuiDisplayGen *)gui
|
||||
{
|
||||
NSEnumerator *cdrEnum;
|
||||
NSArray *cdrArray=
|
||||
[NSArray arrayWithObjects: @"test one", @"test two", @"test three",
|
||||
nil];
|
||||
NSString *cdrName;
|
||||
int row=STARTROW;
|
||||
|
||||
cdrEnum=[cdrArray objectEnumerator];
|
||||
while((cdrName=[cdrEnum nextObject]) != nil)
|
||||
{
|
||||
[gui setText:cdrName forRow:row align:GUI_ALIGN_CENTER];
|
||||
row++;
|
||||
}
|
||||
[gui setSelectableRange:
|
||||
NSMakeRange(STARTROW, STARTROW + [cdrArray count])];
|
||||
}
|
||||
|
||||
- (void) commanderSelector
|
||||
: (GuiDisplayGen *)gui
|
||||
: (MyOpenGLView *)gameView
|
||||
{
|
||||
[self handleGUIUpDownArrowKeys: gui :gameView :-1];
|
||||
}
|
||||
|
||||
@end
|
@ -48,6 +48,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
#import "ShipEntity.h"
|
||||
#import "HeadUpDisplay.h"
|
||||
|
||||
@class GuiDisplayGen;
|
||||
|
||||
#define SCRIPT_TIMER_INTERVAL 10.0
|
||||
|
||||
#define GUI_SCREEN_MAIN 000
|
||||
@ -64,6 +66,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
#define GUI_SCREEN_CONTRACTS 116
|
||||
#define GUI_SCREEN_INVENTORY 107
|
||||
#define GUI_SCREEN_OPTIONS 108
|
||||
#define GUI_SCREEN_LOAD 118
|
||||
#define GUI_SCREEN_SAVE 128
|
||||
#define GUI_SCREEN_MISSION 201
|
||||
#define GUI_SCREEN_REPORT 301
|
||||
|
||||
@ -508,6 +512,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
- (void) pollFlightControls:(double) delta_t;
|
||||
- (void) pollFlightArrowKeyControls:(double) delta_t;
|
||||
- (void) pollGuiArrowKeyControls:(double) delta_t;
|
||||
- (void) handleGUIUpDownArrowKeys:(GuiDisplayGen *)gui
|
||||
:(MyOpenGLView *)gameView
|
||||
:(int) miss_row;
|
||||
- (void) pollViewControls;
|
||||
- (void) pollGuiScreenControls;
|
||||
- (void) pollGameOverControls:(double) delta_t;
|
||||
|
@ -49,6 +49,10 @@ Your fair use and other rights are in no way affected by the above.
|
||||
#import "AI.h"
|
||||
#import "MyOpenGLView.h"
|
||||
|
||||
#ifdef GNUSTEP
|
||||
#import "LoadSave.h"
|
||||
#endif
|
||||
|
||||
@implementation PlayerEntity
|
||||
|
||||
- (void) init_keys
|
||||
@ -3312,6 +3316,48 @@ static BOOL upDownKeyPressed;
|
||||
static int oldSelection;
|
||||
static BOOL selectPressed;
|
||||
static BOOL queryPressed;
|
||||
|
||||
// DJS: Moved from the big switch/case block in pollGuiArrowKeyControls
|
||||
- (void) handleGUIUpDownArrowKeys
|
||||
: (GuiDisplayGen *)gui
|
||||
: (MyOpenGLView *)gameView
|
||||
: (int) miss_row
|
||||
{
|
||||
if ([gameView isDown:gvArrowKeyDown])
|
||||
{
|
||||
if ((!upDownKeyPressed) ||
|
||||
(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
if ([gui setSelectedRow:[gui selectedRow] + 1])
|
||||
{
|
||||
if ([gui selectedRow] == miss_row)
|
||||
[gui setSelectedRow:[gui selectedRow] + 1];
|
||||
[gui click];
|
||||
[universe guiUpdated];
|
||||
}
|
||||
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
if ([gameView isDown:gvArrowKeyUp])
|
||||
{
|
||||
if ((!upDownKeyPressed) ||
|
||||
(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
if ([gui setSelectedRow:[gui selectedRow] - 1])
|
||||
{
|
||||
if ([gui selectedRow] == miss_row)
|
||||
[gui setSelectedRow:[gui selectedRow] - 1];
|
||||
[gui click];
|
||||
[universe guiUpdated];
|
||||
}
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
upDownKeyPressed = (([gameView isDown:gvArrowKeyUp])
|
||||
|| ([gameView isDown:gvArrowKeyDown]));
|
||||
}
|
||||
|
||||
- (void) pollGuiArrowKeyControls:(double) delta_t
|
||||
{
|
||||
MyOpenGLView *gameView = (MyOpenGLView *)[universe gameView];
|
||||
@ -3453,6 +3499,14 @@ static BOOL queryPressed;
|
||||
queryPressed = NO;
|
||||
break;
|
||||
|
||||
// DJS: Farm off load/save screen options to LoadSave.m
|
||||
case GUI_SCREEN_LOAD:
|
||||
[self commanderSelector: gui :gameView];
|
||||
break;
|
||||
|
||||
case GUI_SCREEN_SAVE:
|
||||
break;
|
||||
|
||||
case GUI_SCREEN_OPTIONS :
|
||||
{
|
||||
int quicksave_row = GUI_ROW_OPTIONS_QUICKSAVE;
|
||||
@ -3475,38 +3529,8 @@ static BOOL queryPressed;
|
||||
GameController *controller = [universe gameController];
|
||||
#endif
|
||||
|
||||
if ([gameView isDown:gvArrowKeyDown])
|
||||
{
|
||||
if ((!upDownKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
|
||||
if ([gui setSelectedRow:[gui selectedRow] + 1])
|
||||
{
|
||||
if ([gui selectedRow] == options_row)
|
||||
[gui setSelectedRow:[gui selectedRow] + 1];
|
||||
[gui click];
|
||||
[universe guiUpdated];
|
||||
}
|
||||
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
if ([gameView isDown:gvArrowKeyUp])
|
||||
{
|
||||
if ((!upDownKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
{
|
||||
if ([gui setSelectedRow:[gui selectedRow] - 1])
|
||||
{
|
||||
if ([gui selectedRow] == options_row)
|
||||
[gui setSelectedRow:[gui selectedRow] - 1];
|
||||
[gui click];
|
||||
[universe guiUpdated];
|
||||
}
|
||||
timeLastKeyPress = script_time;
|
||||
}
|
||||
}
|
||||
upDownKeyPressed = (([gameView isDown:gvArrowKeyUp])||([gameView isDown:gvArrowKeyDown]));
|
||||
|
||||
[self handleGUIUpDownArrowKeys: gui :gameView :options_row];
|
||||
|
||||
if ([gameView isDown:13]) // 'enter'
|
||||
{
|
||||
if (([gui selectedRow] == quicksave_row)&&(!disc_operation_in_progress))
|
||||
@ -3541,10 +3565,15 @@ static BOOL queryPressed;
|
||||
if (([gui selectedRow] == load_row)&&(!disc_operation_in_progress))
|
||||
{
|
||||
disc_operation_in_progress = YES;
|
||||
// DJS: WIP
|
||||
//#ifdef GNUSTEP
|
||||
// [self setGuiToLoadCommanderScreen];
|
||||
//#else
|
||||
if ([[universe gameController] inFullScreenMode])
|
||||
[[universe gameController] pauseFullScreenModeToPerform:@selector(loadPlayer) onTarget:self];
|
||||
else
|
||||
[self loadPlayer];
|
||||
//#endif
|
||||
}
|
||||
if (([gui selectedRow] == begin_new_row)&&(!disc_operation_in_progress))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user