From b623f5953691b2a0614e6f1f4def86bdbb9a4113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 8 Aug 2020 11:53:00 +0200 Subject: New upstream version 5.2.0Beta2.1 --- app/bin/dcustmgm.c | 73 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 15 deletions(-) (limited to 'app/bin/dcustmgm.c') diff --git a/app/bin/dcustmgm.c b/app/bin/dcustmgm.c index 8455958..39bd085 100644 --- a/app/bin/dcustmgm.c +++ b/app/bin/dcustmgm.c @@ -41,11 +41,20 @@ #include "paths.h" #include "track.h" #include "wlib.h" +#include "include/paramfilelist.h" +#ifdef WINDOWS +#include "include/utf8convert.h" +#endif static void CustomEdit( void * action ); static void CustomDelete( void * action ); static void CustomExport( void * action ); static void CustomDone( void * action ); +static void CustomNewCar( void * action ); + +static const char * customTypes[] = { "Car Part", "Car Prototype", NULL }; +static wIndex_t selectedType; + static wPos_t customListWidths[] = { 18, 100, 30, 80, 220 }; static const char * customListTitles[] = { "", N_("Manufacturer"), N_("Scale"), N_("Part No"), N_("Description") }; @@ -53,17 +62,17 @@ static paramListData_t customListData = { 10, 400, 5, customListWidths, customLi static paramData_t customPLs[] = { #define I_CUSTOMLIST (0) #define customSelL ((wList_p)customPLs[I_CUSTOMLIST].control) - { PD_LIST, NULL, "inx", PDO_DLGRESETMARGIN|PDO_DLGRESIZE, &customListData, NULL, BL_MANY }, -#define I_CUSTOMEDIT (1) + { PD_LIST, NULL, "inx", PDO_DLGRESETMARGIN|PDO_DLGRESIZE|PDO_DLGBOXEND, &customListData, NULL, BL_MANY }, +#define I_CUSTOMNEWTYPE (1) + { PD_DROPLIST, &selectedType, "newtype", PDO_DLGRESETMARGIN | PDO_LISTINDEX, (void*)150, N_("Create a new ") }, +#define I_CUSTOMNEW (2) + { PD_BUTTON, (void *)CustomNewCar, "newcar", PDO_DLGHORZ| PDO_DLGBOXEND, NULL, N_("Go") }, +#define I_CUSTOMEDIT (3) { PD_BUTTON, (void*)CustomEdit, "edit", PDO_DLGCMDBUTTON, NULL, N_("Edit") }, -#define I_CUSTOMDEL (2) +#define I_CUSTOMDEL (4) { PD_BUTTON, (void*)CustomDelete, "delete", 0, NULL, N_("Delete") }, -#define I_CUSTOMCOPYTO (3) +#define I_CUSTOMCOPYTO (5) { PD_BUTTON, (void*)CustomExport, "export", 0, NULL, N_("Move To") }, -#define I_CUSTOMNEW (4) - { PD_MENU, NULL, "new", PDO_DLGWIDE, NULL, N_("New") }, - { PD_MENUITEM, (void*)CarDlgAddDesc, "new-part-mi", 0, NULL, N_("Car Part") }, - { PD_MENUITEM, (void*)CarDlgAddProto, "new-proto-mi", 0, NULL, N_("Car Prototype") } } ; static paramGroup_t customPG = { "custmgm", 0, customPLs, sizeof customPLs/sizeof customPLs[0] }; @@ -84,6 +93,10 @@ static void CustomDlgUpdate( wIndex_t selcnt = wListGetSelectedCount( (wList_p)customPLs[0].control ); wIndex_t linx, lcnt; + if ( inx == I_CUSTOMNEW ) { + lcnt = wListGetCount( (wList_p)pg->paramPtr[I_CUSTOMNEWTYPE].control ); + } + if ( inx != I_CUSTOMLIST ) return; if ( selcnt == 1 ) { lcnt = wListGetCount( (wList_p)pg->paramPtr[inx].control ); @@ -129,6 +142,20 @@ static void CustomEdit( void * action ) #endif } +static void CustomNewCar( void * action ) +{ + + switch(selectedType) { + case 1: // car prototype + CarDlgAddProto(); + break; + case 0: // car part + CarDlgAddDesc(); + break; + default: + break; + } +} static void CustomDelete( void * action ) { @@ -212,8 +239,17 @@ static int CustomDoExport( oldLocale = SaveLocale("C"); - if ( rc == -1 ) - fprintf( customMgmF, "CONTENTS %s\n", custMgmContentsStr ); + if (rc == -1) + { + #ifdef WINDOWS + char *contents = MyStrdup(custMgmContentsStr); + contents = Convert2UTF8(contents); + fprintf(customMgmF, "CONTENTS %s\n", contents); + MyFree(contents); + #else + fprintf(customMgmF, "CONTENTS %s\n", custMgmContentsStr); + #endif // WINDOWS + } cnt = wListGetCount( (wList_p)customPLs[0].control ); for ( inx=0; inx