Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
GuiDisplayGen.h
Go to the documentation of this file.
1/*
2
3GuiDisplayGen.h
4
5Class handling interface elements, primarily text, that are not part of the 3D
6game world, together with GuiDisplayGen.
7
8Oolite
9Copyright (C) 2004-2013 Giles C Williams and contributors
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software
23Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24MA 02110-1301, USA.
25
26*/
27
28#import "OOCocoa.h"
29#import "OOMaths.h"
30#import "OOTypes.h"
31#include <jsapi.h>
32
33
34#define GUI_DEFAULT_COLUMNS 6
35#define GUI_DEFAULT_ROWS 30
36
37#define GUI_MAX_ROWS 64
38#define GUI_MAX_COLUMNS 40
39#define MAIN_GUI_PIXEL_HEIGHT 480
40#define MAIN_GUI_PIXEL_WIDTH 480
41#define MAIN_GUI_ROW_HEIGHT 16
42#define MAIN_GUI_ROW_WIDTH 16
43#define MAIN_GUI_PIXEL_ROW_START 40
44
45
52
66
67#define GUI_KEY_OK @"OK"
68#define GUI_KEY_SKIP @"SKIP-ROW"
69
70// globals
71static NSString * const kGuiDefaultTextColor = @"default_text_color";
72static NSString * const kGuiScreenTitleColor = @"screen_title_color";
73static NSString * const kGuiScreenDividerColor = @"screen_divider_color";
74static NSString * const kGuiSelectedRowBackgroundColor = @"selected_row_background_color";
75static NSString * const kGuiSelectedRowColor = @"selected_row_color";
76static NSString * const kGuiTextInputCursorColor = @"text_input_cursor_color";
77// F3
78static NSString * const kGuiEquipmentCashColor = @"equipment_cash_color";
79static NSString * const kGuiEquipmentUnavailableColor = @"equipment_unavailable_color";
80static NSString * const kGuiEquipmentScrollColor = @"equipment_scroll_color";
81static NSString * const kGuiEquipmentOptionColor = @"equipment_option_color";
82static NSString * const kGuiEquipmentRepairColor = @"equipment_repair_color";
83static NSString * const kGuiEquipmentDescriptionColor = @"equipment_description_color";
84static NSString * const kGuiEquipmentLaserColor = @"equipment_laser_color";
85static NSString * const kGuiEquipmentLaserFittedColor = @"equipment_laser_fitted_color";
86static NSString * const kGuiEquipmentTabs = @"equipment_tabs";
87// F3 F3
88static NSString * const kGuiShipyardHeadingColor = @"shipyard_heading_color";
89static NSString * const kGuiShipyardScrollColor = @"shipyard_scroll_color";
90static NSString * const kGuiShipyardEntryColor = @"shipyard_entry_color";
91static NSString * const kGuiShipyardNoshipColor = @"shipyard_noship_color";
92static NSString * const kGuiShipyardTradeinColor = @"shipyard_tradein_color";
93static NSString * const kGuiShipyardDescriptionColor = @"shipyard_description_color";
94static NSString * const kGuiShipyardTabs = @"shipyard_tabs";
95// F4
96static NSString * const kGuiInterfaceHeadingColor = @"interface_heading_color";
97static NSString * const kGuiInterfaceScrollColor = @"interface_scroll_color";
98static NSString * const kGuiInterfaceEntryColor = @"interface_entry_color";
99static NSString * const kGuiInterfaceDescriptionColor = @"interface_description_color";
100static NSString * const kGuiInterfaceNoneColor = @"interface_none_color";
101static NSString * const kGuiInterfaceTabs = @"interface_tabs";
102// F5
103static NSString * const kGuiStatusShipnameColor = @"status_shipname_color";
104static NSString * const kGuiStatusDataColor = @"status_data_color";
105static NSString * const kGuiStatusEquipmentHeadingColor = @"status_equipment_heading_color";
106static NSString * const kGuiStatusEquipmentScrollColor = @"status_equipment_scroll_color";
107static NSString * const kGuiStatusEquipmentOkColor = @"status_equipment_ok_color";
108static NSString * const kGuiStatusEquipmentDamagedColor = @"status_equipment_damaged_color";
109static NSString * const kGuiStatusTabs = @"status_tabs";
110static NSString * const kGuiStatusPrioritiseDamaged = @"status_prioritise_damaged";
111// F5 F5
112static NSString * const kGuiManifestSubheadColor = @"manifest_subhead_color";
113static NSString * const kGuiManifestEntryColor = @"manifest_entry_color";
114static NSString * const kGuiManifestScrollColor = @"manifest_scroll_color";
115static NSString * const kGuiManifestNoScrollColor = @"manifest_no_scroll_color";
116static NSString * const kGuiManifestTabs = @"manifest_tabs";
117// F6
118static NSString * const kGuiChartLabelScale = @"chart_label_scale";
119static NSString * const kGuiChartCircleScale = @"chart_circle_scale";
120static NSString * const kGuiChartLabelColor = @"chart_label_color";
121static NSString * const kGuiChartLabelReachableColor = @"chart_labelreachable_color";
122static NSString * const kGuiChartRangeColor = @"chart_range_color";
123static NSString * const kGuiChartCrosshairColor = @"chart_crosshair_color";
124static NSString * const kGuiChartCursorColor = @"chart_cursor_color";
125static NSString * const kGuiChartInfoMarkerColor = @"chart_info_marker_color";
126static NSString * const kGuiChartMatchBoxColor = @"chart_match_box_color";
127static NSString * const kGuiChartMatchLabelColor = @"chart_match_label_color";
128static NSString * const kGuiChartConnectionColor = @"chart_connection_color";
129static NSString * const kGuiChartCurrentJumpStartColor = @"chart_currentjumpstart_color";
130static NSString * const kGuiChartCurrentJumpEndColor = @"chart_currentjumpend_color";
131static NSString * const kGuiChartRouteShortColor = @"chart_route_short_color";
132static NSString * const kGuiChartRouteQuickColor = @"chart_route_quick_color";
133static NSString * const kGuiChartTraveltimeTabs = @"chart_traveltime_tabs";
134
135static NSString * const kGuiChartEconomyUColor = @"chart_economy_%lu_color";
136static NSString * const kGuiChartGovernmentUColor = @"chart_government_%lu_color";
137static NSString * const kGuiChartTechColor = @"chart_tech_color";
138// F7
139static NSString * const kGuiSystemdataFactsColor = @"systemdata_facts_color";
140static NSString * const kGuiSystemdataDescriptionColor = @"systemdata_description_color";
141static NSString * const kGuiSystemdataTabs = @"systemdata_tabs";
142// F8
143static NSString * const kGuiMarketHeadingColor = @"market_heading_color";
144static NSString * const kGuiMarketCommodityColor = @"market_commodity_color";
145static NSString * const kGuiMarketScrollColor = @"market_scroll_color";
146static NSString * const kGuiMarketFilteredAllColor = @"market_filtered_all_color";
147static NSString * const kGuiMarketFilterInfoColor = @"market_filter_info_color";
148static NSString * const kGuiMarketCashColor = @"market_cash_color";
149// F8 F8 extras
150static NSString * const kGuiMarketContractedColor = @"market_contracted_color";
151static NSString * const kGuiMarketDescriptionColor = @"market_description_color";
152static NSString * const kGuiMarketTabs = @"market_tabs";
153// Docking report
154static NSString * const kGuiDockingReportColor = @"docking_report_color";
155static NSString * const kGuiDockingSummaryColor = @"docking_summary_color";
156static NSString * const kGuiDockingContinueColor = @"docking_continue_color";
157
158
159
161
162
163typedef NSInteger OOGUIRow; // -1 for none
164typedef NSInteger OOGUITabStop; // negative value = right align text
166
167
168@interface GuiDisplayGen: NSObject
169{
170@private
172 unsigned n_columns;
173 unsigned n_rows;
178
180
182
186
190
191 NSString *title;
192
193 NSMutableArray *rowText;
194 NSMutableArray *rowKey;
195 NSMutableArray *rowColor;
196
198
199 NSPoint rowPosition[GUI_MAX_ROWS];
201 float rowFadeTime[GUI_MAX_ROWS];
202
204
205 NSDictionary *guiUserSettings;
206
207 NSRange rowRange;
208
211
214
215 GLfloat max_alpha; // main alpha setting
216 GLfloat fade_alpha; // for fade-in / fade-out
217 GLfloat fade_sign; // -1.0 to 1.0
218 NSUInteger statusPage; // status screen: paging equipped items
220}
221
222- (id) init;
223- (id) initWithPixelSize:(NSSize)gui_size
224 columns:(int)gui_cols
225 rows:(int)gui_rows
226 rowHeight:(int)gui_row_height
227 rowStart:(int)gui_row_start
228 title:(NSString*)gui_title;
229
230- (void) resizeWithPixelSize:(NSSize)gui_size
231 columns:(int)gui_cols
232 rows:(int)gui_rows
233 rowHeight:(int)gui_row_height
234 rowStart:(int)gui_row_start
235 title:(NSString*) gui_title;
236- (void) resizeTo:(NSSize)gui_size
237 characterHeight:(int)csize
238 title:(NSString*)gui_title;
239- (NSSize)size;
240- (unsigned)columns;
241- (unsigned)rows;
242- (unsigned)rowHeight;
243- (int)rowStart;
244
245- (NSString *)title;
246- (void) setTitle:(NSString *)str;
247
248- (void) dealloc;
249
250- (void) setDrawPosition:(Vector) vector;
251- (Vector) drawPosition;
252
253- (NSDictionary *) userSettings;
254
255- (void) fadeOutFromTime:(OOTimeAbsolute) now_time overDuration:(OOTimeDelta) duration;
256- (void) stopFadeOuts;
257
258- (GLfloat) alpha;
259- (void) setAlpha:(GLfloat) an_alpha;
260- (void) setMaxAlpha:(GLfloat) an_alpha;
261
262- (void) setBackgroundColor:(OOColor*) color;
263
264- (OOColor *) textColor;
265- (void) setTextColor:(OOColor*) color;
266- (OOColor *) textCommsColor;
267- (void) setTextCommsColor:(OOColor*) color;
268- (OOColor *) colorFromSetting:(NSString *)setting defaultValue:(OOColor *)def;
269- (void) setGLColorFromSetting:(NSString *)setting defaultValue:(OOColor *)def alpha:(GLfloat)alpha;
270- (void) setGuiColorSettingFromKey:(NSString *) key color:(OOColor *)col;
271
272- (void) setCharacterSize:(NSSize) character_size;
273
274- (void) setShowAdvancedNavArray:(BOOL)inFlag;
275
276- (void) setColor:(OOColor *)color forRow:(OOGUIRow)row;
277
278- (id) objectForRow:(OOGUIRow)row;
279- (NSString *) keyForRow:(OOGUIRow)row;
280- (OOGUIRow) rowForKey:(NSString*)key;
281- (OOGUIRow) selectedRow;
282- (BOOL) setSelectedRow:(OOGUIRow)row;
283- (BOOL) setNextRow:(int) direction;
284- (BOOL) setFirstSelectableRow;
285- (BOOL) setLastSelectableRow;
286- (void) setNoSelectedRow;
287- (NSString *) selectedRowText;
288- (NSString *) selectedRowKey;
289
290- (void) setShowTextCursor:(BOOL) yesno;
291- (void) setCurrentRow:(OOGUIRow) value;
292
293- (NSRange) selectableRange;
294- (void) setSelectableRange:(NSRange) range;
295
296- (void) setTabStops:(OOGUITabSettings)stops;
297- (void) overrideTabs:(OOGUITabSettings)stops from:(NSString *)setting length:(NSUInteger)len;
298
299
300- (void) clear;
301- (void) clearAndKeepBackground:(BOOL)keepBackground;
302
303- (void) setKey:(NSString *)str forRow:(OOGUIRow)row;
304- (void) setText:(NSString *)str forRow:(OOGUIRow)row;
305- (void) setText:(NSString *)str forRow:(OOGUIRow)row align:(OOGUIAlignment)alignment;
306- (NSString *) reflowTextForMFD:(NSString *)input;
307- (OOGUIRow) addLongText:(NSString *)str
308 startingAtRow:(OOGUIRow)row
309 align:(OOGUIAlignment)alignment;
310- (void) printLongText:(NSString *)str
311 align:(OOGUIAlignment)alignment
312 color:(OOColor *)text_color
313 fadeTime:(float)text_fade
314 key:(NSString *)text_key
315 addToArray:(NSMutableArray *)text_array;
316- (void) printLineNoScroll:(NSString *)str
317 align:(OOGUIAlignment)alignment
318 color:(OOColor *)text_color
319 fadeTime:(float)text_fade
320 key:(NSString *)text_key
321 addToArray:(NSMutableArray *)text_array;
322
323- (void) setArray:(NSArray *)arr forRow:(OOGUIRow)row;
324
325- (void) insertItemsFromArray:(NSArray *)items
326 withKeys:(NSArray *)item_keys
327 intoRow:(OOGUIRow)row
328 color:(OOColor *)text_color;
329
331
332- (void) scrollUp:(int) how_much;
333
334/* allows the use of special dynamic backgrounds */
335- (void) setBackgroundTextureSpecial:(OOGUIBackgroundSpecial)spec withBackground:(BOOL)withBackground;
336
337/*
338 A background/foreground texture descriptor is a dictionary with a string
339 property keyed "name" and optional number properties keyed "width" and
340 "height".
341*/
342
343- (BOOL) setBackgroundTextureDescriptor:(NSDictionary *)descriptor;
344- (BOOL) setForegroundTextureDescriptor:(NSDictionary *)descriptor;
345- (BOOL) setBackgroundTextureKey:(NSString *)key;
346- (BOOL) setForegroundTextureKey:(NSString *)key;
347
348- (BOOL) preloadGUITexture:(NSDictionary *)descriptor;
349
350/*
351 Interpret a JavaScript value as a texture descriptor for
352 -[GUIDisplayGen set{Background|Foreground}TextureDescriptor:]. Also starts
353 preloading the texture.
354
355 callerDescription is a string describing the context in which this was
356 called, generally a method name (like "mission.runScreen()") for warning
357 generation.
358
359 Requires a request on context.
360*/
361- (NSDictionary *) textureDescriptorFromJSValue:(jsval)value inContext:(JSContext *)context callerDescription:(NSString *)callerDescription;
362
363- (void) clearBackground;
364
365- (void) leaveLastLine;
366- (NSArray *) getLastLines;
367
368- (int) drawGUI:(GLfloat) alpha drawCursor:(BOOL) drawCursor;
369- (void) drawGUIBackground;
370- (void) setStatusPage:(NSInteger) pageNum;
371- (NSUInteger) statusPage;
372- (void) refreshStarChart;
373- (void) setStarChartTitle;
374
375- (OOSystemID) targetNextFoundSystem:(int)direction;
376
377@end
static NSString *const kGuiDockingReportColor
static NSString *const kGuiInterfaceTabs
static NSString *const kGuiChartTechColor
static NSString *const kGuiShipyardEntryColor
static NSString *const kGuiDockingContinueColor
static NSString *const kGuiTextInputCursorColor
static NSString *const kGuiEquipmentOptionColor
static NSString *const kGuiChartCrosshairColor
static NSString *const kGuiStatusEquipmentOkColor
static NSString *const kGuiManifestNoScrollColor
static NSString *const kGuiEquipmentLaserColor
static NSString *const kGuiShipyardHeadingColor
static NSString *const kGuiChartMatchBoxColor
static NSString *const kGuiInterfaceHeadingColor
static NSString *const kGuiInterfaceEntryColor
static NSString *const kGuiDockingSummaryColor
static NSString *const kGuiEquipmentUnavailableColor
static NSString *const kGuiStatusPrioritiseDamaged
static NSString *const kGuiChartGovernmentUColor
static NSString *const kGuiChartConnectionColor
static NSString *const kGuiManifestTabs
#define GUI_MAX_COLUMNS
static NSString *const kGuiSystemdataTabs
static NSString *const kGuiStatusEquipmentHeadingColor
static NSString *const kGuiChartRouteShortColor
static NSString *const kGuiChartCurrentJumpEndColor
static NSString *const kGuiSelectedRowColor
OOGUIBackgroundSpecial
@ GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST
@ GUI_BACKGROUND_SPECIAL_LONG
@ GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST
@ GUI_BACKGROUND_SPECIAL_SHORT
@ GUI_BACKGROUND_SPECIAL_NONE
@ GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_CUSTOM
@ GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST
static NSString *const kGuiMarketCommodityColor
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
static NSString *const kGuiShipyardNoshipColor
NSInteger OOGUITabStop
static NSString *const kGuiDefaultTextColor
static NSString *const kGuiChartCursorColor
static NSString *const kGuiEquipmentCashColor
static NSString *const kGuiChartLabelScale
static NSString *const kGuiChartLabelColor
static NSString *const kGuiMarketDescriptionColor
static NSString *const kGuiChartMatchLabelColor
static NSString *const kGuiSelectedRowBackgroundColor
static NSString *const kGuiEquipmentDescriptionColor
static NSString *const kGuiShipyardTabs
static NSString *const kGuiManifestScrollColor
static NSString *const kGuiShipyardTradeinColor
static NSString *const kGuiEquipmentTabs
static NSString *const kGuiSystemdataFactsColor
static NSString *const kGuiChartCircleScale
static NSString *const kGuiMarketScrollColor
static NSString *const kGuiChartInfoMarkerColor
static NSString *const kGuiInterfaceDescriptionColor
static NSString *const kGuiMarketTabs
static NSString *const kGuiEquipmentRepairColor
static NSString *const kGuiMarketHeadingColor
static NSString *const kGuiShipyardDescriptionColor
static NSString *const kGuiMarketContractedColor
static NSString *const kGuiScreenTitleColor
static NSString *const kGuiManifestSubheadColor
static NSString *const kGuiShipyardScrollColor
static NSString *const kGuiChartLabelReachableColor
static NSString *const kGuiStatusEquipmentDamagedColor
static NSString *const kGuiScreenDividerColor
static NSString *const kGuiSystemdataDescriptionColor
NSInteger OOGUIRow
static NSString *const kGuiChartRouteQuickColor
OOGUIAlignment
@ GUI_ALIGN_RIGHT
@ GUI_ALIGN_LEFT
@ GUI_ALIGN_CENTER
static NSString *const kGuiChartCurrentJumpStartColor
static NSString *const kGuiInterfaceScrollColor
static NSString *const kGuiChartTraveltimeTabs
static NSString *const kGuiMarketFilterInfoColor
static NSString *const kGuiStatusEquipmentScrollColor
static NSString *const kGuiStatusTabs
static NSString *const kGuiManifestEntryColor
static NSString *const kGuiChartEconomyUColor
static NSString *const kGuiEquipmentScrollColor
static NSString *const kGuiMarketCashColor
static NSString *const kGuiChartRangeColor
static NSString *const kGuiStatusDataColor
static NSString *const kGuiStatusShipnameColor
static NSString *const kGuiInterfaceNoneColor
static NSString *const kGuiEquipmentLaserFittedColor
static NSString *const kGuiMarketFilteredAllColor
int16_t OOSystemID
Definition OOTypes.h:211
double OOTimeDelta
Definition OOTypes.h:224
double OOTimeAbsolute
Definition OOTypes.h:223
OOTextureSprite * foregroundSprite
unsigned n_columns
NSRange selectableRange
NSMutableArray * rowColor
float rowFadeTime[GUI_MAX_ROWS]
OOTextureSprite * backgroundSprite
OOSystemID foundSystem
OOColor * textColor
OOGUIBackgroundSpecial backgroundSpecial
NSSize pixel_text_size
OOGUIRow selectedRow
NSMutableArray * rowText
OOGUIAlignment rowAlignment[GUI_MAX_ROWS]
NSSize size_in_pixels
NSString * title
NSSize pixel_title_size
OOGUIRow currentRow
OOGUITabSettings tabStops
NSUInteger statusPage
unsigned pixel_row_height
NSMutableArray * rowKey
NSDictionary * guiUserSettings
BOOL showAdvancedNavArray
NSPoint rowPosition[GUI_MAX_ROWS]
OOColor * backgroundColor
OOColor * textCommsColor
voidpf void uLong size
Definition ioapi.h:134
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque