-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.c
More file actions
1361 lines (1207 loc) · 56.6 KB
/
main.c
File metadata and controls
1361 lines (1207 loc) · 56.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
* Sevgi_Editor *
* TODO: - A loading window that displays each load progress. *
* - Localize strings *
******************************************************************************/
///defines
#define PROGRAMNAME "Sevgi Editor"
#define VERSION 0
#define REVISION 160
#define VERSIONSTRING "0.160"
#define AUTHOR "Ibrahim Alper Sönmez"
#define COPYRIGHT "@ 2024 " AUTHOR
#define CONTACT "amithlondestek@gmail.com"
#define DESCRIPTION "Game Editor for Sevgi Engine"
//define command line syntax and number of options
#define RDARGS_TEMPLATE ""
#define RDARGS_OPTIONS 0
//#define or #undef GENERATEWBMAIN to enable workbench startup
#define GENERATEWBMAIN
#define MUIV_App_RetID_New_Project_Window_Open 0x01
#define MUIV_App_RetID_New_Project_Window_Close 0x02
#define MUIV_App_RetID_New_Project_Create 0x03
#define MUIV_App_RetID_Load_Project 0x04
#define MUIV_App_RetID_Save_Project 0x05
#define MUIV_App_RetID_Save_Project_As 0x06
#define MUIV_App_RetID_Edited 0x07
#define MUIV_App_RetID_Open_In_IDE 0x08
#define MUIV_App_RetID_Make 0x09
#define MUIV_App_RetID_Make_Clean 0x0A
#define MUIV_App_RetID_Run 0x0B
#define MEN_PROJECT 50
#define MEN_NEW_PROJECT MUIV_App_RetID_New_Project_Window_Open
#define MEN_LOAD_PROJECT MUIV_App_RetID_Load_Project
#define MEN_SAVE_PROJECT MUIV_App_RetID_Save_Project
#define MEN_SAVE_PROJECT_AS MUIV_App_RetID_Save_Project_As
#define MEN_ABOUT 51
#define MEN_ABOUTMUI 52
#define MEN_QUIT MUIV_Application_ReturnID_Quit
#define MEN_SETTINGS 53
#define MEN_EDITOR_SETTINGS 54
#define MEN_HELP 55
#define MEN_HELP_ENGINE 56
#define MEN_HELP_EDITOR 57
#define PROJECTS_DIR "Projects"
///
///includes
//standard headers
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
//Amiga headers
#include <exec/exec.h>
#include <dos/dos.h>
#include <dos/dostags.h>
#include <dos/dosextens.h>
#include <dos/datetime.h>
#include <graphics/gfx.h>
#include <graphics/gfxmacros.h>
#include <graphics/layers.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>
#include <workbench/icon.h>
#include <datatypes/pictureclass.h>
#include <libraries/asl.h>
#include <libraries/commodities.h>
#include <libraries/gadtools.h>
#include <libraries/iffparse.h>
#include <libraries/locale.h>
#include <rexx/rxslib.h>
#include <rexx/storage.h>
#include <rexx/errors.h>
#include <utility/hooks.h>
//Amiga protos
#include <clib/alib_protos.h>
#include <proto/asl.h>
#include <proto/commodities.h>
#include <proto/datatypes.h>
#include <proto/diskfont.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/graphics.h>
#include <proto/icon.h>
#include <proto/iffparse.h>
#include <proto/intuition.h>
#include <proto/layers.h>
#include <proto/locale.h>
#include <proto/rexxsyslib.h>
#include <proto/utility.h>
#include <proto/wb.h>
/* MUI headers */
#include <libraries/mui.h>
#include <proto/muimaster.h>
#include <workbench/workbench.h>
//SDI headers
#include <SDI_compiler.h>
#include <SDI_hook.h>
#include <SDI_interrupt.h>
#include <SDI_lib.h>
#include <SDI_misc.h>
#include <SDI_stdarg.h>
#include "utility.h"
#include "toolbar.h"
#include "popasl_string.h"
#include "ackstring.h"
#include "integer_gadget.h"
#include "gamefont_creator.h"
#include "tileset_creator.h"
#include "tilemap_creator.h"
#include "bobsheet_creator.h"
#include "spritebank_creator.h"
#include "color_gadget.h"
#include "color_palette.h"
#include "palette_editor.h"
#include "image_display.h"
#include "image_editor.h"
#include "game_settings.h"
#include "assets_editor.h"
#include "dtpicdisplay.h"
#include "new_project.h"
#include "editor_settings.h"
#include "palette_selector.h"
#include "display_creator.h"
#include "bitmap_selector.h"
///
///structs
/***********************************************
* Global configuration struct for this program *
************************************************/
struct Config
{
struct RDArgs *RDArgs;
//command line options
#if RDARGS_OPTIONS
LONG Options[RDARGS_OPTIONS];
#endif
BPTR initial_dir;
};
//<YOUR STRUCTS HERE>
///
///globals
/***********************************************
* Version string for this program *
************************************************/
#if defined(__SASC)
const UBYTE VersionTag[] = "$VER: " PROGRAMNAME " " VERSIONSTRING " " __AMIGADATE__ "\n\0";
#elif defined(_DCC)
const UBYTE VersionTag[] = "$VER: " PROGRAMNAME " " VERSIONSTRING " (" __COMMODORE_DATE__ ")\n\0";
#elif defined(__GNUC__)
__attribute__((section(".text"))) volatile static const UBYTE VersionTag[] = "$VER: " PROGRAMNAME " " VERSIONSTRING " (" __DATE__ ")\n\0";
#else
const UBYTE VersionTag[] = "$VER: " PROGRAMNAME " " VERSIONSTRING " (" __DATE__ ")\n\0";
#endif
APTR g_MemoryPool = NULL;
struct FileRequester* g_FileReq = NULL;
struct FontRequester* g_FontReq = NULL;
struct {
STRPTR convert_tiles;
STRPTR convert_map;
STRPTR bob_sheeter;
STRPTR sprite_banker;
STRPTR gob_banker;
struct {
BOOL convert_tiles;
BOOL convert_map;
BOOL bob_sheeter;
BOOL sprite_banker;
BOOL gob_banker;
}avail;
}g_Tools = {"Tools/ConvertTiles",
"Tools/ConvertMap",
"Tools/BobSheeter",
"Tools/SpriteBanker",
"Tools/GOBBanker",
{FALSE, FALSE, FALSE, FALSE, FALSE}};
ULONG g_Program_Stack_Size = 8192;
BPTR g_System_Path_List = NULL;
BPTR g_Program_Directory_Lock = NULL;
STRPTR g_Program_Directory = NULL;
STRPTR g_Program_Executable = NULL;
STRPTR g_Win_Title = NULL;
BOOL g_First_Run = FALSE;
struct Project {
STRPTR directory;
STRPTR settings_header;
STRPTR assets_header;
STRPTR palettes_header;
STRPTR data_drawer;
STRPTR assets_drawer;
ULONG screen_depth;
}g_Project = {NULL, NULL, NULL, NULL, NULL, NULL, 0};
///
///MUI globals
#ifdef __GNUC__
/* Otherwise auto open will try version 37, and muimaster.library has version
19.x for MUI 3.8 */
int __oslibversion = 0;
#endif
struct Library *CyberGfxBase = NULL;
struct Library *AslBase;
struct Library *MUIMasterBase;
#if defined(__amigaos4__)
struct CyberGfxIFace *ICyberGfx = NULL;
struct AslIFace *IAsl;
struct MUIMasterIFace *IMUIMaster;
#endif
struct MUI_CustomClass* MUIC_PopASLString = NULL;
struct MUI_CustomClass* MUIC_Integer = NULL;
struct MUI_CustomClass* MUIC_AckString = NULL;
struct MUI_CustomClass* MUIC_GamefontCreator = NULL;
struct MUI_CustomClass* MUIC_TilesetCreator = NULL;
struct MUI_CustomClass* MUIC_TilemapCreator = NULL;
struct MUI_CustomClass* MUIC_BobsheetCreator = NULL;
struct MUI_CustomClass* MUIC_SpritebankCreator = NULL;
struct MUI_CustomClass* MUIC_ImageDisplay = NULL;
struct MUI_CustomClass* MUIC_ImageEditor = NULL;
struct MUI_CustomClass* MUIC_ColorGadget = NULL;
struct MUI_CustomClass* MUIC_ColorPalette = NULL;
struct MUI_CustomClass* MUIC_PaletteEditor = NULL;
struct MUI_CustomClass* MUIC_SettingsEditor = NULL;
struct MUI_CustomClass* MUIC_AssetsEditor = NULL;
struct MUI_CustomClass* MUIC_DtPicDisplay = NULL;
struct MUI_CustomClass* MUIC_NewProject = NULL;
struct MUI_CustomClass* MUIC_EditorSettings = NULL;
struct MUI_CustomClass* MUIC_PaletteSelector = NULL;
struct MUI_CustomClass* MUIC_DisplayCreator = NULL;
struct MUI_CustomClass* MUIC_BitmapSelector = NULL;
struct Window* g_Window;
Object *App, *Win;
Object *AboutMUIWin = NULL;
Object *g_dtPicDisplay = NULL;
Object *g_Settings = NULL;
struct {
Object* newProject;
Object* gameFontCreator;
Object* tilesetCreator;
Object* tilemapCreator;
Object* bobsheetCreator;
Object* spritebankCreator;
Object* imageEditor;
Object* settingsEditor;
Object* assetsEditor;
Object* paletteEditor;
Object* dtPicDisplay;
Object* settings;
Object* paletteSelector;
Object* displayCreator;
Object* bitmapSelector;
}window;
struct {
Object* new;
Object* load;
Object* save;
Object* settings;
Object* assets;
Object* editor;
Object* font;
Object* tileset;
Object* tilemap;
Object* bobsheet;
Object* sprite;
Object* image;
Object* object;
Object* palette;
Object* display;
Object* compile;
Object* run;
}toolbar;
struct {
Object* compile;
Object* compile_list;
}popup;
#define POP_MAKE 0
#define POP_MAKE_CLEAN 1
STRPTR popl_compile_array[] = {"make", "make clean", NULL};
///
///prototypes
/***********************************************
* Function forward declarations *
************************************************/
int main (int argc, char **argv);
int wbmain (struct WBStartup *wbs);
struct Config *Init (void);
int Main (struct Config *config);
void CleanUp(struct Config *config);
Object * buildGUI(void);
VOID checkAvailTools(VOID);
VOID sleepAll(BOOL sleep);
VOID openProject(STRPTR directory);
VOID saveProject();
VOID saveProjectAs();
BOOL checkEditedState();
VOID openInIDE();
VOID openGuide(ULONG id);
VOID runProject(VOID);
VOID makeProject(STRPTR cmd);
///
///init
/***********************************************
* Program initialization *
* - Allocates the config struct to store the *
* global configuration data. *
* - Do your other initial allocations here. *
************************************************/
struct Config *Init()
{
struct Config *config;
#if defined(__amigaos4__)
g_MemoryPool = AllocSysObjectTags(ASOT_MEMPOOL, ASOPOOL_MFlags, MEMF_ANY | MEMF_CLEAR,
ASOPOOL_Puddle, 2048,
ASOPOOL_Threshold, 2048,
ASOPOOL_Name, "Sevgi_Editor pool",
ASOPOOL_LockMem, FALSE,
TAG_DONE);
#else
g_MemoryPool = CreatePool(MEMF_ANY | MEMF_CLEAR, 2048, 2048);
#endif
if (!g_MemoryPool) return NULL;
config = (struct Config*)AllocPooled(g_MemoryPool, sizeof(struct Config));
if (config)
{
checkAvailTools();
g_Program_Directory = getProgDir();
}
return(config);
}
///
///entry
/***********************************************
* Ground level entry point *
* - Branches regarding Shell/WB call. *
***********************************************/
int main(int argc, char **argv)
{
int rc = 20;
g_Program_Stack_Size = getProgramStackSize();
//argc != 0 identifies call from shell
if (argc)
{
struct Config *config = Init();
g_Program_Executable = FilePart(argv[0]);
if (config) {
config->initial_dir = CurrentDir(GetProgramDir());
#if RDARGS_OPTIONS
// parse command line arguments
if (config->RDArgs = ReadArgs(RDARGS_TEMPLATE, config->Options, NULL))
rc = Main(config);
else
PrintFault(IoErr(), PROGRAMNAME);
#else
rc = Main(config);
#endif
CleanUp(config);
}
}
else {
g_Program_Executable = ((struct WBStartup*) argv)->sm_ArgList->wa_Name;
g_System_Path_List = getSystemPathList((struct WBStartup *)argv);
rc = wbmain((struct WBStartup *)argv);
}
return(rc);
}
/***********************************************
* Workbench main *
* - This executable was called from Workbench *
***********************************************/
int wbmain(struct WBStartup *wbs)
{
int rc = 20;
#ifdef GENERATEWBMAIN
struct Config *config = Init();
if (config) {
//<SET Config->Options[] HERE>
rc = Main(config);
CleanUp(config);
}
#endif
return(rc);
}
///
///prepareMenu()
STATIC struct NewMenu* prepareMenu()
{
#define MENU_SIZE 16
struct NewMenu* menu = (struct NewMenu*) AllocPooled(g_MemoryPool, sizeof(struct NewMenu) * MENU_SIZE);
if (menu) {
menu[0].nm_Type = NM_TITLE;
menu[0].nm_Label = "Project";
menu[0].nm_UserData = (APTR)MEN_PROJECT;
menu[1].nm_Type = NM_ITEM;
menu[1].nm_Label = "New...";
menu[1].nm_CommKey = "N";
menu[1].nm_UserData = (APTR)MEN_NEW_PROJECT;
menu[2].nm_Type = NM_ITEM;
menu[2].nm_Label = "Load...";
menu[2].nm_CommKey = "L";
menu[2].nm_UserData = (APTR)MEN_LOAD_PROJECT;
menu[3].nm_Type = NM_ITEM;
menu[3].nm_Label = "Save";
menu[3].nm_CommKey = "S";
menu[3].nm_Flags = NM_ITEMDISABLED;
menu[3].nm_UserData = (APTR)MEN_SAVE_PROJECT;
menu[4].nm_Type = NM_ITEM;
menu[4].nm_Label = "Save As...";
menu[4].nm_CommKey = "A";
menu[4].nm_Flags = NM_ITEMDISABLED;
menu[4].nm_UserData = (APTR)MEN_SAVE_PROJECT_AS;
menu[5].nm_Type = NM_ITEM;
menu[5].nm_Label = NM_BARLABEL;
menu[6].nm_Type = NM_ITEM;
menu[6].nm_Label = "About...";
menu[6].nm_UserData = (APTR)MEN_ABOUT;
menu[7].nm_Type = NM_ITEM;
menu[7].nm_Label = "About MUI...";
menu[7].nm_UserData = (APTR)MEN_ABOUTMUI;
menu[8].nm_Type = NM_ITEM;
menu[8].nm_Label = NM_BARLABEL;
menu[9].nm_Type = NM_ITEM;
menu[9].nm_Label = "Quit";
menu[9].nm_CommKey = "Q";
menu[9].nm_UserData = (APTR)MEN_QUIT;
menu[10].nm_Type = NM_TITLE;
menu[10].nm_Label = "Settings";
menu[10].nm_UserData = (APTR)MEN_SETTINGS;
menu[11].nm_Type = NM_ITEM;
menu[11].nm_Label = "Editor Settings...";
menu[11].nm_UserData = (APTR)MEN_EDITOR_SETTINGS;
menu[12].nm_Type = NM_TITLE;
menu[12].nm_Label = "Help";
menu[12].nm_UserData = (APTR)MEN_HELP;
menu[13].nm_Type = NM_ITEM;
menu[13].nm_Label = "Engine...";
menu[13].nm_UserData = (APTR)MEN_HELP_ENGINE;
menu[14].nm_Type = NM_ITEM;
menu[14].nm_Label = "Editor...";
menu[14].nm_UserData = (APTR)MEN_HELP_EDITOR;
menu[15].nm_Type = NM_END;
return menu;
}
return NULL;
}
///
///MUI hooks
// Packs List Display Hook
HOOKPROTO(pop_compile_func, VOID, Object* list, Object* str)
{
ULONG selected = 0;
get(list, MUIA_List_Active, &selected);
switch (selected) {
case POP_MAKE:
DoMethod(App, MUIM_Application_ReturnID, MUIV_App_RetID_Make);
break;
case POP_MAKE_CLEAN:
DoMethod(App, MUIM_Application_ReturnID, MUIV_App_RetID_Make_Clean);
break;
}
}
MakeStaticHook(pop_compile_hook, pop_compile_func);
///
///buildGUI
/***********************************************
* Program main window *
* - Creates the MUI Application object. *
***********************************************/
Object *buildGUI()
{
App = MUI_NewObject(MUIC_Application,
MUIA_Application_Author, (ULONG)AUTHOR,
MUIA_Application_Base, (ULONG)PROGRAMNAME,
MUIA_Application_Copyright, (ULONG)COPYRIGHT,
MUIA_Application_Description, (ULONG)DESCRIPTION,
MUIA_Application_Title, (ULONG)PROGRAMNAME,
MUIA_Application_Version, (ULONG)VersionTag,
MUIA_Application_Window, (Win = MUI_NewObject(MUIC_Window,
MUIA_Window_ID, MAKE_ID('S','V','G','E'),
MUIA_Window_Title, (ULONG)PROGRAMNAME,
MUIA_Window_Menustrip, MUI_MakeObject(MUIO_MenustripNM, (ULONG)prepareMenu(), 0),
MUIA_Window_RootObject, MUI_NewObject(MUIC_Group,
MUIA_Group_Child, MUI_NewObject(MUIC_Group,
MUIA_Group_Horiz, TRUE,
MUIA_Group_HorizSpacing, 0,
MUIA_Group_Child, (toolbar.new = MUI_NewImageButton(IMG_SPEC_NEW, "New Game", MUIA_Enabled)),
MUIA_Group_Child, (toolbar.load = MUI_NewImageButton(IMG_SPEC_LOAD, "Load Game", MUIA_Enabled)),
MUIA_Group_Child, (toolbar.save = MUI_NewImageButton(IMG_SPEC_SAVE, "Save Game", MUIA_Disabled)),
MUIA_Group_Child, MUI_NewImageButtonSeparator(),
MUIA_Group_Child, (toolbar.settings = MUI_NewImageButton(IMG_SPEC_SETTINGS, "Game Settings", MUIA_Disabled)),
MUIA_Group_Child, (toolbar.assets = MUI_NewImageButton(IMG_SPEC_ASSETS, "Assets Editor", MUIA_Disabled)),
MUIA_Group_Child, (toolbar.palette = MUI_NewImageButton(IMG_SPEC_PALETTE, "Palette Editor", MUIA_Disabled)),
MUIA_Group_Child, (toolbar.display = MUI_NewImageButton(IMG_SPEC_DISPLAY, "Display Creator", MUIA_Disabled)),
MUIA_Group_Child, MUI_NewImageButtonSeparator(),
MUIA_Group_Child, (toolbar.editor = MUI_NewImageButton(IMG_SPEC_EDITOR, "Open in IDE", MUIA_Disabled)),
MUIA_Group_Child, (popup.compile = MUI_NewObject(MUIC_Popobject,
MUIA_Popstring_Button, (toolbar.compile = MUI_NewImageButton(IMG_SPEC_COMPILE, "Compile Project", MUIA_Disabled)),
MUIA_Popobject_Object, (popup.compile_list = MUI_NewObject(MUIC_Listview,
MUIA_FixWidthTxt, popl_compile_array[POP_MAKE_CLEAN],
MUIA_FixHeightTxt, "\n\n",
MUIA_Background, MUII_SHINE,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Listview_ScrollerPos, MUIV_Listview_ScrollerPos_None,
MUIA_Listview_MultiSelect, MUIV_Listview_MultiSelect_None,
MUIA_Listview_List, MUI_NewObject(MUIC_List,
MUIA_Background, MUII_SHINE,
MUIA_List_SourceArray, popl_compile_array,
TAG_END),
TAG_END)),
MUIA_Popobject_ObjStrHook, &pop_compile_hook,
TAG_END)),
MUIA_Group_Child, (toolbar.run = MUI_NewImageButton(IMG_SPEC_RUN, "Run Project", MUIA_Disabled)),
MUIA_Group_Child, MUI_NewImageButtonSeparator(),
MUIA_Group_Child, (toolbar.font = MUI_NewImageButton(IMG_SPEC_FONT, "Gamefont Creator", MUIA_Enabled)),
MUIA_Group_Child, (toolbar.tileset = MUI_NewImageButton(IMG_SPEC_TILE, "Tileset Creator", g_Tools.avail.convert_tiles ? MUIA_Enabled : MUIA_Disabled)),
MUIA_Group_Child, (toolbar.tilemap = MUI_NewImageButton(IMG_SPEC_MAP, "Tilemap Creator", g_Tools.avail.convert_map ? MUIA_Enabled : MUIA_Disabled)),
MUIA_Group_Child, (toolbar.bobsheet = MUI_NewImageButton(IMG_SPEC_BOB, "BobSheet Creator", g_Tools.avail.bob_sheeter ? MUIA_Enabled : MUIA_Disabled)),
MUIA_Group_Child, (toolbar.sprite = MUI_NewImageButton(IMG_SPEC_SPRITE, "Sprite Bank Creator", g_Tools.avail.sprite_banker ? MUIA_Enabled : MUIA_Disabled)),
MUIA_Group_Child, (toolbar.image = MUI_NewImageButton(IMG_SPEC_IMAGE, "Image Hotspot and Hitbox Editor", MUIA_Enabled)),
MUIA_Group_Child, (toolbar.object = MUI_NewImageButton(IMG_SPEC_OBJECTS, "GameObject Editor (NOT IMPLEMENTED)", g_Tools.avail.gob_banker ? MUIA_Enabled : MUIA_Disabled)),
MUIA_Group_Child, MUI_NewObject(MUIC_Rectangle, TAG_END),
TAG_END),
TAG_END),
TAG_END)),
MUIA_Application_Window, (window.gameFontCreator = NewObject(MUIC_GamefontCreator->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.tilesetCreator = NewObject(MUIC_TilesetCreator->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.tilemapCreator = NewObject(MUIC_TilemapCreator->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.bobsheetCreator = NewObject(MUIC_BobsheetCreator->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.spritebankCreator = NewObject(MUIC_SpritebankCreator->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.imageEditor = NewObject(MUIC_ImageEditor->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.paletteEditor = NewObject(MUIC_PaletteEditor->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.settingsEditor = NewObject(MUIC_SettingsEditor->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.assetsEditor = NewObject(MUIC_AssetsEditor->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.dtPicDisplay = g_dtPicDisplay = NewObject(MUIC_DtPicDisplay->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.newProject = NewObject(MUIC_NewProject->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.settings = g_Settings = NewObject(MUIC_EditorSettings->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.paletteSelector = NewObject(MUIC_PaletteSelector->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.displayCreator = NewObject(MUIC_DisplayCreator->mcc_Class, NULL, TAG_END)),
MUIA_Application_Window, (window.bitmapSelector = NewObject(MUIC_BitmapSelector->mcc_Class, NULL, TAG_END)),
TAG_END);
//Notifications
if (App) {
Object* tsc_add_zero;
Object* tmc_add_zero;
Object* lst_palettes;
Object* chk_aga;
Object* chk_clp;
get(Win, MUIA_Window_Window, &g_Window);
DoMethod(popup.compile_list, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE, popup.compile, 2,
MUIM_Popstring_Close, TRUE);
DoMethod(toolbar.run, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_Run);
DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
DoMethod(toolbar.font, MUIM_Notify, MUIA_Pressed, FALSE, window.gameFontCreator, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.tileset, MUIM_Notify, MUIA_Pressed, FALSE, window.tilesetCreator, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.tilemap, MUIM_Notify, MUIA_Pressed, FALSE, window.tilemapCreator, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.bobsheet, MUIM_Notify, MUIA_Pressed, FALSE, window.bobsheetCreator, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.sprite, MUIM_Notify, MUIA_Pressed, FALSE, window.spritebankCreator, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.image, MUIM_Notify, MUIA_Pressed, FALSE, window.imageEditor, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.palette, MUIM_Notify, MUIA_Pressed, FALSE, window.paletteEditor, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.display, MUIM_Notify, MUIA_Pressed, FALSE, window.displayCreator, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.settings, MUIM_Notify, MUIA_Pressed, FALSE, window.settingsEditor, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(toolbar.assets, MUIM_Notify, MUIA_Pressed, FALSE, window.assetsEditor, 3,
MUIM_Set, MUIA_Window_Open, TRUE);
get(window.tilesetCreator, MUIA_TilesetCreator_AddZeroButton, &tsc_add_zero);
get(window.tilemapCreator, MUIA_TilemapCreator_AddZeroButton, &tmc_add_zero);
DoMethod(tsc_add_zero, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, tmc_add_zero, 3,
MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
DoMethod(tmc_add_zero, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, tsc_add_zero, 3,
MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
DoMethod(toolbar.new, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_New_Project_Window_Open);
DoMethod(window.newProject, MUIM_Notify, MUIA_Window_Open, FALSE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_New_Project_Window_Close);
DoMethod(window.newProject, MUIM_Notify, MUIA_NewProject_Create, TRUE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_New_Project_Create);
DoMethod(toolbar.load, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_Load_Project);
DoMethod(toolbar.save, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_Save_Project);
DoMethod(window.settingsEditor, MUIM_Notify, MUIA_GameSettings_Edited, TRUE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_Edited);
DoMethod(window.assetsEditor, MUIM_Notify, MUIA_AssetsEditor_Edited, TRUE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_Edited);
DoMethod(window.paletteEditor, MUIM_Notify, MUIA_PaletteEditor_Edited, TRUE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_Edited);
get(window.paletteEditor, MUIA_PaletteEditor_List, &lst_palettes);
DoMethod(window.paletteSelector, MUIM_Set, MUIA_PaletteSelector_SourceList, lst_palettes);
DoMethod(window.assetsEditor, MUIM_Set, MUIA_AssetsEditor_PaletteSelector, window.paletteSelector);
DoMethod(window.displayCreator, MUIM_Set, MUIA_DisplayCreator_PaletteSelector, window.paletteSelector);
DoMethod(window.assetsEditor, MUIM_Set, MUIA_AssetsEditor_BitmapSelector, window.bitmapSelector);
DoMethod(window.settingsEditor, MUIM_Set, MUIA_GameSettings_AssetsEditor, window.assetsEditor);
get(window.settingsEditor, MUIA_GameSettings_AGACheck, &chk_aga);
DoMethod(window.displayCreator, MUIM_Set, MUIA_DisplayCreator_AGACheck, chk_aga);
get(window.settingsEditor, MUIA_GameSettings_CLPCheck, &chk_clp);
DoMethod(window.displayCreator, MUIM_Set, MUIA_DisplayCreator_CLPCheck, chk_clp);
DoMethod(toolbar.editor, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
MUIM_Application_ReturnID, MUIV_App_RetID_Open_In_IDE);
}
return App;
}
///
///main
/***********************************************
* Developer level main *
* - Code your program here. *
***********************************************/
int Main(struct Config *config)
{
int rc = 0;
AslBase = OpenLibrary("asl.library", 0);
if (AslBase) {
#if defined(__amigaos4__)
if ((IAsl = (struct AslIFace*)GetInterface(AslBase, "main", 1, NULL))) {
#endif
MUIMasterBase = OpenLibrary("muimaster.library", 0);
if (MUIMasterBase) {
#if defined(__amigaos4__)
if ((IMUIMaster = (struct MUIMasterIFace *)GetInterface(MUIMasterBase, "main", 1, NULL))) {
#endif
if ((g_FileReq = MUI_AllocAslRequestTags(ASL_FileRequest, TAG_END))) {
if ((g_FontReq = MUI_AllocAslRequestTags(ASL_FontRequest, TAG_END))) {
if ((MUIC_PopASLString = MUI_Create_PopASLString())) {
if ((MUIC_AckString = MUI_Create_AckString())) {
if ((MUIC_Integer = MUI_Create_Integer())) {
if ((MUIC_DtPicDisplay = MUI_Create_DtPicDisplay())) {
if ((MUIC_GamefontCreator = MUI_Create_GamefontCreator())) {
if ((MUIC_TilesetCreator = MUI_Create_TilesetCreator())) {
if ((MUIC_TilemapCreator = MUI_Create_TilemapCreator())) {
if ((MUIC_BobsheetCreator = MUI_Create_BobsheetCreator())) {
if ((MUIC_SpritebankCreator = MUI_Create_SpritebankCreator())) {
if ((MUIC_ColorGadget = MUI_Create_ColorGadget())) {
if ((MUIC_ColorPalette = MUI_Create_ColorPalette())) {
if ((MUIC_PaletteEditor = MUI_Create_PaletteEditor())) {
if ((MUIC_ImageDisplay = MUI_Create_ImageDisplay())) {
if ((MUIC_ImageEditor = MUI_Create_ImageEditor())) {
if ((MUIC_SettingsEditor = MUI_Create_GameSettings())) {
if ((MUIC_AssetsEditor = MUI_Create_AssetsEditor())) {
if ((MUIC_NewProject = MUI_Create_NewProject())) {
if ((MUIC_EditorSettings = MUI_Create_EditorSettings())) {
if ((MUIC_PaletteSelector = MUI_Create_PaletteSelector())) {
if ((MUIC_DisplayCreator = MUI_Create_DisplayCreator())) {
if ((MUIC_BitmapSelector = MUI_Create_BitmapSelector())) {
if (createImageSpecs()) {
if (buildGUI()) {
ULONG signals = 0;
BOOL running = TRUE;
set(Win, MUIA_Window_Open, TRUE);
//Open cybergraphics.library if we are on an RTG display
if (GetBitMapAttr(_rp(toolbar.new)->BitMap, BMA_DEPTH) > 8) {
CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
if (CyberGfxBase) {
#if defined(__amigaos4__)
if (!(ICyberGfx = (struct CyberGfxIFace*)GetInterface(CyberGfxBase, "main", 1, NULL))) {
rc = 20;
running = FALSE;
}
#endif
}
else {
rc = 20;
running = FALSE;
}
}
//Open settings window if this is the first run of the editor
if (g_First_Run) {
set(window.settings, MUIA_Window_Open, TRUE);
}
while(running)
{
ULONG id = DoMethod (App, MUIM_Application_NewInput, &signals);
switch(id)
{
case MEN_ABOUT:
MUI_Request(App, Win, NULL, "About " PROGRAMNAME, "*_Ok",
PROGRAMNAME " v" VERSIONSTRING "\n\n%s " AUTHOR "\n%s " CONTACT, (ULONG)"Programming:", (ULONG)"Contact:");
break;
case MEN_ABOUTMUI:
if (!AboutMUIWin) {
AboutMUIWin = MUI_NewObject(MUIC_Aboutmui,
MUIA_Window_RefWindow, Win,
MUIA_Aboutmui_Application, App,
TAG_END);
}
if (AboutMUIWin)
set(AboutMUIWin, MUIA_Window_Open, TRUE);
break;
case MUIV_Application_ReturnID_Quit:
if (checkEditedState()) {
running = FALSE;
}
break;
case MUIV_App_RetID_New_Project_Window_Open:
if (checkEditedState()) {
sleepAll(TRUE);
DoMethod(window.newProject, MUIM_Set, MUIA_Window_Open, TRUE);
}
break;
case MUIV_App_RetID_New_Project_Window_Close:
sleepAll(FALSE);
break;
case MUIV_App_RetID_New_Project_Create:
{
STRPTR name = NULL;
STRPTR drawer = NULL;
STRPTR directory = NULL;
get(window.newProject, MUIA_NewProject_Name, &name);
get(window.newProject, MUIA_NewProject_Drawer, &drawer);
directory = makePath(drawer, name, NULL);
replaceChars(FilePart(directory), " ", '_');
openProject(directory);
freeString(directory);
}
break;
case MUIV_App_RetID_Load_Project:
{
if (checkEditedState()) {
sleepAll(TRUE);
if (MUI_AslRequestTags(g_FileReq, ASLFR_TitleText, "Select the project drawer to open",
ASLFR_Window, g_Window,
ASLFR_SleepWindow, TRUE,
ASLFR_PositiveText, "Open",
ASLFR_DrawersOnly, TRUE,
ASLFR_DoSaveMode, FALSE,
ASLFR_DoPatterns, FALSE,
ASLFR_InitialDrawer, PROJECTS_DIR "/",
TAG_END) && strlen(g_FileReq->fr_Drawer)) {
openProject(g_FileReq->fr_Drawer);
}
sleepAll(FALSE);
}
}
break;
case MUIV_App_RetID_Save_Project:
saveProject();
break;
case MUIV_App_RetID_Save_Project_As:
saveProjectAs();
break;
case MUIV_App_RetID_Edited:
DoMethod(toolbar.save, MUIM_Set, MUIA_Disabled, FALSE);
DoMethod(Win, MUIM_Window_SetMenuState, MEN_SAVE_PROJECT, TRUE);
break;
case MEN_EDITOR_SETTINGS:
DoMethod(window.settings, MUIM_Set, MUIA_Window_Open, TRUE);
break;
case MEN_HELP_ENGINE:
openGuide(MEN_HELP_ENGINE);
break;
case MEN_HELP_EDITOR:
openGuide(MEN_HELP_EDITOR);
break;
case MUIV_App_RetID_Open_In_IDE:
openInIDE();
break;
case MUIV_App_RetID_Make:
makeProject("make");
break;
case MUIV_App_RetID_Make_Clean:
makeProject("make clean");
break;
case MUIV_App_RetID_Run:
runProject();
break;
case MUIM_PaletteEditor_Reset:
case MUIM_PaletteEditor_LoadAs:
case MUIM_PaletteEditor_SaveAs:
case MUIM_PaletteEditor_Import_ILBM:
case MUIM_PaletteEditor_Export_ILBM:
case MUIM_PaletteEditor_Append_ILBM:
case MUIM_PaletteEditor_Merge_ILBM:
DoMethod(window.paletteEditor, id);
break;
}
if(running && signals) signals = Wait(signals | SIGBREAKF_CTRL_C);
if (signals & SIGBREAKF_CTRL_C) break;
}
// Close cybergraphics.library if it was opened
#if defined(__amigaos4__)
if (ICyberGfx) {
DropInterface((struct Interface *)ICyberGfx);
}
#endif
if (CyberGfxBase) {
CloseLibrary(CyberGfxBase);
}
set(Win, MUIA_Window_Open, FALSE);
MUI_DisposeObject(App);
}
else rc = 20;
freeImageSpecs();
}
MUI_DeleteCustomClass(MUIC_BitmapSelector);
}
MUI_DeleteCustomClass(MUIC_DisplayCreator);
}
MUI_DeleteCustomClass(MUIC_PaletteSelector);
}
MUI_DeleteCustomClass(MUIC_EditorSettings);
}
MUI_DeleteCustomClass(MUIC_NewProject);
}
MUI_DeleteCustomClass(MUIC_AssetsEditor);
}
MUI_DeleteCustomClass(MUIC_SettingsEditor);
}
MUI_DeleteCustomClass(MUIC_ImageEditor);
}
MUI_DeleteCustomClass(MUIC_ImageDisplay);
}
MUI_DeleteCustomClass(MUIC_PaletteEditor);
}
MUI_DeleteCustomClass(MUIC_ColorPalette);
}
MUI_DeleteCustomClass(MUIC_ColorGadget);
}
MUI_DeleteCustomClass(MUIC_SpritebankCreator);
}
MUI_DeleteCustomClass(MUIC_BobsheetCreator);
}
MUI_DeleteCustomClass(MUIC_TilemapCreator);
}
MUI_DeleteCustomClass(MUIC_TilesetCreator);
}
MUI_DeleteCustomClass(MUIC_GamefontCreator);
}
MUI_DeleteCustomClass(MUIC_DtPicDisplay);
}
MUI_DeleteCustomClass(MUIC_Integer);
}
MUI_DeleteCustomClass(MUIC_AckString);
}
MUI_DeleteCustomClass(MUIC_PopASLString);
}
MUI_FreeAslRequest(g_FontReq);
}
MUI_FreeAslRequest(g_FileReq);
}
#if defined(__amigaos4__)
DropInterface((struct Interface *)IMUIMaster);
}
else rc = 20;
#endif
CloseLibrary(MUIMasterBase);
}
else rc = 20;
#if defined(__amigaos4__)
DropInterface((struct Interface *)IAsl);
}
else rc = 20;
#endif
CloseLibrary(AslBase);
}
else rc = 20;
return(rc);
}
///
///cleanup
/***********************************************
* Clean up before exit *
* - Free allocated resources here. *
***********************************************/
void CleanUp(struct Config *config)
{
if (config)
{
//<YOUR CLEAN UP CODE HERE>
// free command line arguments
#if RDARGS_OPTIONS
if (config->RDArgs)
FreeArgs(config->RDArgs);
#endif
if (config->initial_dir) {
CurrentDir(config->initial_dir);
}
FreePooled(g_MemoryPool, config, sizeof(struct Config));
}
if (g_MemoryPool) {
#if defined(__amigaos4__)
FreeSysObject(ASOT_MEMPOOL, g_MemoryPool);