OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4AppDelegate+MainMenuActions.mm
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
5  *
6  * Distributed under the terms of the ISC license; see accompanying file
7  * "COPYING" for details.
8  *
9  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
10  * See accompanying file "TRADEMARK" for details.
11  *
12  * To redistribute this file separately, substitute the full license texts
13  * for the above references.
14  */
15 
16 #include <GL/glew.h>
17 
18 #include "C4Include.h"
19 #include "editor/C4Console.h"
20 #include "game/C4Viewport.h"
21 #include "game/C4GraphicsSystem.h"
22 
24 #import "graphics/C4DrawGLMac.h"
26 
27 @implementation C4AppDelegate (MainMenuActions)
28 
29 - (IBAction) openScenario:(id)sender
30 {
31  Console.FileOpen();
32 }
33 
34 - (IBAction) openScenarioWithPlayers:(id)sender
35 {
37 }
38 
39 - (IBAction) closeScenario:(id)sender
40 {
42  [editorWindowController.window setRepresentedFilename:@""];
43 }
44 
45 
46 - (IBAction) saveGameAs:(id)sender
47 {
48  Console.FileSaveAs(true);
49 }
50 
51 - (IBAction) saveScenario:(id)sender
52 {
53  Console.FileSave();
54 }
55 
56 - (IBAction) saveScenarioAs:(id)sender
57 {
58  Console.FileSaveAs(false);
59 }
60 
61 - (IBAction) record:(id)sender
62 {
64 }
65 
66 - (IBAction) newViewport:(id)sender
67 {
69 }
70 
71 - (IBAction) newViewportForPlayer:(id)sender
72 {
73  ::Viewports.CreateViewport([sender tag]);
74 }
75 
76 - (IBAction) joinPlayer:(id)sender
77 {
79 }
80 
81 - (IBAction) openPropTools:(id)sender;
82 {
84 }
85 
86 - (IBAction) showAbout:(id)sender;
87 {
89 }
90 
91 - (IBAction) toggleFullScreen:(id)sender
92 {
94  {
95  NSBeep();
96  return;
97  }
98  [gameWindowController setFullscreen:Config.Graphics.Windowed];
100 
101 }
102 
103 - (IBAction) togglePause:(id)sender
104 {
105  [self simulateKeyPressed:K_PAUSE];
106 }
107 
108 - (IBAction) setConsoleMode:(id)sender
109 {
110  [editorWindowController selectMode:sender];
111  [editorWindowController.modeSelector selectSegmentWithTag:[sender tag]];
112 }
113 
114 - (IBAction) setDrawingTool:(id)sender
115 {
116  [editorWindowController selectTool:sender];
117  [editorWindowController.toolSelector selectSegmentWithTag:[sender tag]];
118 }
119 
120 - (IBAction) suggestQuitting:(id)sender;
121 {
123  {
124  NSLog(@"Game running, only simulating Esc key");
125  [self simulateKeyPressed:K_ESCAPE];
126  }
127  else
128  {
129  if (Application.isEditor)
130  Console.FileClose();
133  Application.Clear();
134  Application.Quit();
135  }
136 }
137 
138 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
139 {
140  // enabled when running in fullscreen
141  if ([item action] == @selector(toggleFullScreen:))
142  return !Application.isEditor;
143 
144  SEL s;
145  int i;
146 
147  SEL gameRunningSelectors[] =
148  {
149  @selector(togglePause:),
150  @selector(makeScreenshot:),
151  @selector(makeScreenshotOfWholeMap:),
152  nil
153  };
154  for (i = 0; (s = gameRunningSelectors[i]) != nil; i++)
155  if ([item action] == s)
156  return Game.IsRunning;
157 
158  // enabled when game running and console mode
159  SEL gameRunningInConsoleModeSelectors[] =
160  {
161  @selector(saveScenario:),
162  @selector(saveScenarioAs:),
163  @selector(saveGameAs:),
164  @selector(record:),
165  @selector(closeScenario:),
166  @selector(newViewport:),
167  @selector(newViewportForPlayer:),
168  @selector(joinPlayer:),
169  @selector(openPropTools:),
170  @selector(setConsoleMode:),
171  @selector(setDrawingTool:),
172  nil
173  };
174  for (i = 0; (s = gameRunningInConsoleModeSelectors[i]) != nil; i++)
175  {
176  if (s == [item action])
178  }
179 
180  // always enabled
181  return YES;
182 }
183 
184 - (IBAction) visitWebsite:(id)sender;
185 {
186  OpenURL("http://wiki.openclonk.org");
187 }
188 
189 - (void) simulateKeyPressed:(C4KeyCode)key
190 {
191  Game.DoKeyboardInput(key, KEYEV_Down, false, false, false, false, NULL);
192  Game.DoKeyboardInput(key, KEYEV_Up, false, false, false, false, NULL);
193 }
194 
195 - (IBAction) makeScreenshot:(id)sender;
196 {
198 }
199 
200 - (IBAction) makeScreenshotOfWholeMap:(id)sender;
201 {
203 }
204 
205 @end
bool FileSaveAs(bool fSaveGame, bool export_packed=false)
Definition: C4Console.cpp:269
C4EditCursor EditCursor
Definition: C4Console.h:90
bool IsRunning
Definition: C4Game.h:139
C4Config Config
Definition: C4Config.cpp:833
C4Console Console
Definition: C4Globals.cpp:45
bool OpenPropTools()
C4Game Game
Definition: C4Globals.cpp:52
void HelpAbout()
Definition: C4Console.cpp:449
bool SaveScreenshotKey(bool fSaveAll)
IBAction simulateKeyPressed:(C4KeyCode key)
int32_t Windowed
Definition: C4Config.h:106
bool FileClose()
Definition: C4Console.cpp:382
bool DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType eEventType, bool fAlt, bool fCtrl, bool fShift, bool fRepeated, class C4GUI::Dialog *pForDialog=nullptr, bool fPlrCtrlOnly=false, int32_t iStrength=-1)
Definition: C4Game.cpp:1865
C4ConfigGraphics Graphics
Definition: C4Config.h:253
void Clear() override
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
void ViewportNew()
Definition: C4Console.cpp:456
bool OpenURL(const char *szURL)
Definition: C4AppMac.mm:198
bool CreateViewport(int32_t iPlayer, bool fSilent=false)
Definition: C4Viewport.cpp:917
bool fQuitMsgReceived
Definition: C4App.h:81
void Quit() override
bool FileOpenWPlrs()
Definition: C4Console.cpp:343
bool FileRecord()
Definition: C4Console.cpp:394
bool FileOpen(const char *filename=nullptr, bool host_in_network=false)
Definition: C4Console.cpp:319
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
bool FileSave()
Definition: C4Console.cpp:262
bool ScheduleProcs(int iTimeout=1000/36)
#define s
unsigned long C4KeyCode
C4Application Application
Definition: C4Globals.cpp:44
void PlayerJoin()
Definition: C4Console.cpp:513