OpenClonk
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 #define GL_SILENCE_DEPRECATION
17 #include <epoxy/gl.h>
18 
19 #include "C4Include.h"
20 #include "editor/C4Console.h"
21 #include "game/C4Viewport.h"
22 #include "game/C4GraphicsSystem.h"
23 
25 #import "graphics/C4DrawGLMac.h"
27 
28 @implementation C4AppDelegate (MainMenuActions)
29 
30 - (IBAction) openScenario:(id)sender
31 {
32  Console.FileOpen();
33 }
34 
35 - (IBAction) openScenarioWithPlayers:(id)sender
36 {
38 }
39 
40 - (IBAction) closeScenario:(id)sender
41 {
43  [editorWindowController.window setRepresentedFilename:@""];
44 }
45 
46 
47 - (IBAction) saveGameAs:(id)sender
48 {
49  Console.FileSaveAs(true);
50 }
51 
52 - (IBAction) saveScenario:(id)sender
53 {
54  Console.FileSave();
55 }
56 
57 - (IBAction) saveScenarioAs:(id)sender
58 {
59  Console.FileSaveAs(false);
60 }
61 
62 - (IBAction) record:(id)sender
63 {
65 }
66 
67 - (IBAction) newViewport:(id)sender
68 {
70 }
71 
72 - (IBAction) newViewportForPlayer:(id)sender
73 {
74  ::Viewports.CreateViewport([sender tag]);
75 }
76 
77 - (IBAction) joinPlayer:(id)sender
78 {
80 }
81 
82 - (IBAction) openPropTools:(id)sender
83 {
85 }
86 
87 - (IBAction) showAbout:(id)sender
88 {
90 }
91 
92 - (IBAction) toggleFullScreen:(id)sender
93 {
95  {
96  NSBeep();
97  return;
98  }
99  [gameWindowController setFullscreen:Config.Graphics.Windowed];
101 
102 }
103 
104 - (IBAction) togglePause:(id)sender
105 {
106  [self simulateKeyPressed:K_PAUSE];
107 }
108 
109 - (IBAction) setConsoleMode:(id)sender
110 {
111  [editorWindowController selectMode:sender];
112  [editorWindowController.modeSelector selectSegmentWithTag:[sender tag]];
113 }
114 
115 - (IBAction) setDrawingTool:(id)sender
116 {
117  [editorWindowController selectTool:sender];
118  [editorWindowController.toolSelector selectSegmentWithTag:[sender tag]];
119 }
120 
121 - (IBAction) suggestQuitting:(id)sender
122 {
124  {
125  NSLog(@"Game running, only simulating Esc key");
126  [self simulateKeyPressed:K_ESCAPE];
127  }
128  else
129  {
130  if (Application.isEditor)
131  Console.FileClose();
134  Application.Clear();
135  Application.Quit();
136  }
137 }
138 
139 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
140 {
141  // enabled when running in fullscreen
142  if ([item action] == @selector(toggleFullScreen:))
143  return !Application.isEditor;
144 
145  SEL s;
146  int i;
147 
148  SEL gameRunningSelectors[] =
149  {
150  @selector(togglePause:),
151  @selector(makeScreenshot:),
152  @selector(makeScreenshotOfWholeMap:),
153  nil
154  };
155  for (i = 0; (s = gameRunningSelectors[i]) != nil; i++)
156  if ([item action] == s)
157  return Game.IsRunning;
158 
159  // enabled when game running and console mode
160  SEL gameRunningInConsoleModeSelectors[] =
161  {
162  @selector(saveScenario:),
163  @selector(saveScenarioAs:),
164  @selector(saveGameAs:),
165  @selector(record:),
166  @selector(closeScenario:),
167  @selector(newViewport:),
168  @selector(newViewportForPlayer:),
169  @selector(joinPlayer:),
170  @selector(openPropTools:),
171  @selector(setConsoleMode:),
172  @selector(setDrawingTool:),
173  nil
174  };
175  for (i = 0; (s = gameRunningInConsoleModeSelectors[i]) != nil; i++)
176  {
177  if (s == [item action])
179  }
180 
181  // always enabled
182  return YES;
183 }
184 
185 - (IBAction) visitWebsite:(id)sender
186 {
187  OpenURL("http://wiki.openclonk.org");
188 }
189 
190 - (void) simulateKeyPressed:(C4KeyCode)key
191 {
192  Game.DoKeyboardInput(key, KEYEV_Down, false, false, false, false, NULL);
193  Game.DoKeyboardInput(key, KEYEV_Up, false, false, false, false, NULL);
194 }
195 
196 - (IBAction) makeScreenshot:(id)sender
197 {
199 }
200 
201 - (IBAction) makeScreenshotOfWholeMap:(id)sender
202 {
204 }
205 
206 @end
bool OpenURL(const char *szURL)
Definition: C4AppMac.mm:199
#define s
C4Config Config
Definition: C4Config.cpp:930
C4Game Game
Definition: C4Globals.cpp:52
C4Console Console
Definition: C4Globals.cpp:45
C4Application Application
Definition: C4Globals.cpp:44
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
@ KEYEV_Up
@ KEYEV_Down
unsigned long C4KeyCode
C4ViewportList Viewports
bool fQuitMsgReceived
Definition: C4App.h:81
void Clear() override
void Quit() override
int32_t Windowed
Definition: C4Config.h:107
C4ConfigGraphics Graphics
Definition: C4Config.h:257
bool FileRecord()
Definition: C4Console.cpp:394
bool FileOpen(const char *filename=nullptr, bool host_in_network=false)
Definition: C4Console.cpp:319
void PlayerJoin()
Definition: C4Console.cpp:513
void HelpAbout()
Definition: C4Console.cpp:449
C4EditCursor EditCursor
Definition: C4Console.h:90
bool FileOpenWPlrs()
Definition: C4Console.cpp:343
bool FileClose()
Definition: C4Console.cpp:382
bool FileSave()
Definition: C4Console.cpp:262
void ViewportNew()
Definition: C4Console.cpp:456
bool FileSaveAs(bool fSaveGame, bool export_packed=false)
Definition: C4Console.cpp:269
bool OpenPropTools()
bool IsRunning
Definition: C4Game.h:140
bool DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType event_type, bool alt, bool ctrl, bool shift, bool repeated, class C4GUI::Dialog *for_dialog=nullptr, bool fPlrCtrlOnly=false, int32_t strength=-1)
Definition: C4Game.cpp:2288
bool SaveScreenshotKey(bool save_all)
bool CreateViewport(int32_t player_nr, bool silent=false)
bool ScheduleProcs(int iTimeout=1000/36)