diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2025-09-20 19:19:34 +0200 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2025-09-20 19:19:34 +0200 |
| commit | e7d20cf352688bf717a01f4e6d9e6f497c2bea4c (patch) | |
| tree | cfd2ef9b569f49af985a6f1ec44f2614f63c8e78 /app/bin/dcmpnd.c | |
| parent | a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (diff) | |
New upstream version 5.3.1Beta2upstream/5.3.1Beta2
Diffstat (limited to 'app/bin/dcmpnd.c')
| -rw-r--r-- | app/bin/dcmpnd.c | 228 |
1 files changed, 36 insertions, 192 deletions
diff --git a/app/bin/dcmpnd.c b/app/bin/dcmpnd.c index 9b7dfcc..99fe657 100644 --- a/app/bin/dcmpnd.c +++ b/app/bin/dcmpnd.c @@ -30,187 +30,8 @@ #include "track.h" #include "trkendpt.h" #include "common-ui.h" +#include "cselect.h" -/***************************************************************************** - * - * Update Titles - * - */ - -static wWin_p updateTitleW; -typedef enum { updateUnknown, updateTurnout, updateStructure } updateType_e; -static updateType_e updateListType; -static BOOL_T updateWVisible; -static BOOL_T updateWStale; -typedef struct { - updateType_e type; - SCALEINX_T scale; - char * old; - char * new; -} updateTitleElement; -static dynArr_t updateTitles_da; -#define updateTitles(N) DYNARR_N( updateTitleElement, updateTitles_da, N ) - -static void UpdateTitleIgnore( void* junk ); -static wIndex_t updateTitleInx; -static paramData_t updateTitlePLs[] = { - { PD_MESSAGE, "This file contains Turnout and Structure Titles which should be updated." }, - { PD_MESSAGE, "This dialog allows you to change the definitions in this file." }, - { PD_MESSAGE, "To replace the old name, choose a definition from the list." }, - { PD_MESSAGE, "If the required definition is not loaded you can use the Load button" }, - { PD_MESSAGE, "to invoke the Parameter Files dialog to load the required Parameter File." }, - { PD_MESSAGE, "If you choose Cancel then the Titles will not be changed and some" }, - { PD_MESSAGE, "features (Price List and Label selection) may not be fully functional." }, - { PD_MESSAGE, "You can use the List Labels control on the Preferences dialog to" }, - { PD_MESSAGE, "control the format of the list entries" }, -#define I_UPDATESTR (9) - { PD_STRING, NULL, "old", PDO_NOPREF, I2VP(400), NULL, BO_READONLY }, -#define I_UPDATELIST (10) -#define updateTitleL ((wList_p)updateTitlePLs[I_UPDATELIST].control) - { PD_DROPLIST, NULL, "sel", PDO_NOPREF, I2VP(400) }, - { PD_BUTTON, UpdateTitleIgnore, "ignore", PDO_DLGCMDBUTTON, NULL, N_("Ignore") }, -#define I_UPDATELOAD (12) - { PD_BUTTON, NULL, "load", 0, NULL, N_("Load") } -}; -static paramGroup_t updateTitlePG = { "updatetitle", 0, updateTitlePLs, COUNT( updateTitlePLs ) }; - - -static void UpdateTitleChange( long changes ) -{ - if ( (changes & (CHANGE_SCALE|CHANGE_PARAMS)) == 0 ) { - return; - } - if (!updateWVisible) { - updateWStale = TRUE; - return; - } - wControlShow( (wControl_p)updateTitleL, FALSE ); - wListClear( updateTitleL ); - if (updateTitles(updateTitleInx).type == updateTurnout) { - TurnoutAdd( listLabels, updateTitles(updateTitleInx).scale, updateTitleL, NULL, - -1 ); - } else { - StructAdd( listLabels, updateTitles(updateTitleInx).scale, updateTitleL, - NULL ); - } - wControlShow( (wControl_p)updateTitleL, TRUE ); - updateListType = updateTitles(updateTitleInx).type; -} - - -static void UpdateTitleNext( void ) -{ - wIndex_t inx; - wIndex_t cnt; - track_p trk; - struct extraDataCompound_t *xx; - updateTitleInx++; - if (updateTitleInx >= updateTitles_da.cnt) { - wHide( updateTitleW ); - updateWVisible = FALSE; - InfoMessage( _("Updating definitions, please wait") ); - cnt = 0; - trk = NULL; - while (TrackIterate( &trk ) ) { - InfoCount(cnt++); - TRKTYP_T trkType = GetTrkType(trk); - if (trkType == T_TURNOUT || trkType == T_STRUCTURE) { - xx = GET_EXTRA_DATA(trk, trkType, extraDataCompound_t); - for (inx=0; inx<updateTitles_da.cnt; inx++) { - if ( updateTitles(inx).old && - strcmp( xx->title, updateTitles(inx).old ) == 0 ) { - xx->title = MyStrdup( updateTitles(inx).new ); - break; - } - } - } - } - DYNARR_RESET( updateTitleElement, updateTitles_da ); - InfoMessage(""); - InfoCount( trackCount ); - SetFileChanged(); - DoChangeNotification( CHANGE_MAIN ); - return; - } - ParamLoadMessage( &updateTitlePG, I_UPDATESTR, - updateTitles(updateTitleInx).old ); - if (updateWStale || updateTitles(updateTitleInx).type != updateListType) { - UpdateTitleChange( CHANGE_SCALE|CHANGE_PARAMS ); - } -} - - -static void UpdateTitleUpdate( void* junk ) -{ - void * selP; - turnoutInfo_t * to; - wListGetValues( updateTitleL, NULL, 0, NULL, &selP ); - if (selP != NULL) { - to = (turnoutInfo_t*)selP; - updateTitles(updateTitleInx).new = to->title; - } - UpdateTitleNext(); -} - -static void UpdateTitleIgnore( void* junk ) -{ - updateTitles(updateTitleInx).old = NULL; - UpdateTitleNext(); -} - -static void UpdateTitleCancel( wWin_p junk ) -{ - wHide( updateTitleW ); - DYNARR_RESET( updateTitleElement, updateTitles_da ); - updateWVisible = FALSE; -} - - -void DoUpdateTitles( void ) -{ - if (updateTitles_da.cnt <= 0) { - return; - } - if (updateTitleW == NULL) { - ParamRegister( &updateTitlePG ); - updateTitlePLs[I_UPDATELOAD].valueP = ParamFilesInit(); - updateTitleW = ParamCreateDialog( &updateTitlePG, - MakeWindowTitle(_("Update Title")), _("Update"), UpdateTitleUpdate, - UpdateTitleCancel, TRUE, NULL, 0, NULL ); - RegisterChangeNotification( UpdateTitleChange ); - } - updateTitleInx = -1; - wShow( updateTitleW ); - updateWVisible = TRUE; - updateListType = updateUnknown; - UpdateTitleNext(); -} - -EXPORT void UpdateTitleMark( - char * title, - SCALEINX_T scale ) -{ - int inx; - updateTitleElement * ut; - if ( inPlayback ) { - return; - } - for (inx=0; inx<updateTitles_da.cnt; inx++) { - if (strcmp(title,updateTitles(inx).old) == 0) { - return; - } - } - DYNARR_APPEND( updateTitleElement, updateTitles_da, 10 ); - ut = &updateTitles(updateTitles_da.cnt-1); - if ( TempEndPtsCount() > 0) { - ut->type = updateTurnout; - } else { - ut->type = updateStructure; - } - ut->scale = scale; - ut->old = MyStrdup(title); - ut->new = NULL; -} /***************************************************************************** * @@ -328,6 +149,7 @@ static dynArr_t refreshSpecial_da; static wIndex_t refreshSpecialInx; static BOOL_T refreshReturnVal; static void RefreshSkip( void * junk ); +static void RefreshDone( void * junk ); static paramListData_t refreshSpecialListData = { 30, 600, 0, NULL, NULL }; static paramData_t refreshSpecialPLs[] = { #define REFRESH_M1 (0) @@ -338,7 +160,8 @@ static paramData_t refreshSpecialPLs[] = { { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, #define REFRESH_L (3) { PD_LIST, &refreshSpecialInx, "list", PDO_LISTINDEX|PDO_NOPREF|PDO_DLGRESIZE, &refreshSpecialListData, NULL, BO_READONLY }, - { PD_BUTTON, RefreshSkip, "skip", PDO_DLGCMDBUTTON, NULL, N_("Skip") } + { PD_BUTTON, RefreshSkip, "skip", PDO_DLGCMDBUTTON, NULL, N_("Skip") }, + { PD_BUTTON, RefreshDone, "done", PDO_DLGCMDBUTTON, NULL, N_("Done") } }; static paramGroup_t refreshSpecialPG = { "refreshSpecial", 0, refreshSpecialPLs, COUNT( refreshSpecialPLs ) }; static void RefreshSpecialOk( @@ -346,8 +169,8 @@ static void RefreshSpecialOk( { wHide( refreshSpecialPG.win ); } -static void RefreshSpecialCancel( - wWin_p win ) +static void RefreshDone( + void * junk ) { refreshSpecialInx = -1; refreshReturnVal = FALSE; @@ -360,7 +183,7 @@ static void RefreshSkip( wHide( refreshSpecialPG.win ); } -EXPORT BOOL_T RefreshCompound( +static BOOL_T RefreshCompound( track_p trk, BOOL_T junk ) { @@ -397,7 +220,8 @@ EXPORT BOOL_T RefreshCompound( } if ( IsParamValid(to->paramFileIndex) && to->segCnt > 0 && - (FIT_NONE != CompatibleScale( GetTrkEndPtCnt(trk)>0, to->scaleInx, scale ) )) { + (FIT_NONE != CompatibleScale( GetTrkEndPtCnt(trk)>0?FIT_TURNOUT:FIT_STRUCTURE, + to->scaleInx, scale ) )) { if ( RefreshCompound1( trk, refreshSpecial(inx).to ) ) { if ( strcasecmp( xx->title, to->title ) != 0 ) { MyFree( xx->title ); @@ -416,8 +240,8 @@ EXPORT BOOL_T RefreshCompound( if ( refreshSpecialPG.win == NULL ) { ParamRegister( &refreshSpecialPG ); ParamCreateDialog( &refreshSpecialPG, - MakeWindowTitle(_("Refresh Turnout/Structure")), _("Ok"), RefreshSpecialOk, - RefreshSpecialCancel, TRUE, NULL, F_BLOCK|F_RESIZE|F_RECALLSIZE, NULL ); + MakeWindowTitle(_("Refresh Turnout/Structure")), _("Replace"), RefreshSpecialOk, + ParamCancel_Null, TRUE, NULL, F_BLOCK|F_RESIZE|F_RECALLSIZE, NULL ); } ParamLoadMessage( &refreshSpecialPG, REFRESH_M1, _("Choose a Turnout/Structure to replace:") ); @@ -468,6 +292,26 @@ EXPORT BOOL_T RefreshCompound( } } +EXPORT void DoRefreshCompound( void * unused ) +{ + if (SelectedTracksAreFrozen()) { + return; + } + refreshSpecialInx = -1; + refreshReturnVal = FALSE; + if (selectedTrackCount>0) { + UndoStart( _("Refresh Compound"), "refresh compound" ); + DoSelectedTracks( RefreshCompound ); + RefreshCompound( NULL, FALSE ); + UndoEnd(); + MainRedraw(); // DoRefreshCompound + } else { + ErrorMessage( MSG_NO_SELECTED_TRK ); + } +} + + + /***************************************************************************** * * Custom Management Support @@ -580,7 +424,7 @@ static int CompoundCustMgmProc( if ( !renamePG.win ) { ParamRegister( &renamePG ); ParamCreateDialog( &renamePG, MakeWindowTitle(_("Rename Object")), _("Ok"), - RenameOk, wHide, TRUE, NULL, F_BLOCK, NULL ); + RenameOk, ParamCancel_Current, TRUE, NULL, F_BLOCK, NULL ); } ParamLoadControls( &renamePG ); wShow( renamePG.win ); @@ -614,8 +458,8 @@ static int CompoundCustMgmProc( } -#include "bitmaps/turnout.xpm3" -#include "bitmaps/building.xpm3" +#include "bitmaps/turnout.image3" +#include "bitmaps/building.image3" EXPORT void CompoundCustMgmLoad( void ) { @@ -625,10 +469,10 @@ EXPORT void CompoundCustMgmLoad( void ) static wIcon_p structI = NULL; if ( turnoutI == NULL ) { - turnoutI = wIconCreatePixMap( turnout_xpm3[0] ); + turnoutI = wIconCreatePixMap( turnout_image3[0] ); } if ( structI == NULL ) { - structI = wIconCreatePixMap( building_xpm3[0] ); + structI = wIconCreatePixMap( building_image3[0] ); } for ( inx=0; inx<turnoutInfo_da.cnt; inx++ ) { |
