diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
commit | df5520aa2dae5b3ce7abf8733dcdd152898af163 (patch) | |
tree | 00d3047bfb14f682bfb5a21010c731ed649bfed7 /app/bin/dcmpnd.c | |
parent | df247efec654e512242e4f4f1b0212034f9e01fe (diff) | |
parent | ec3c0f6f6e7153fa797dc57a0e95779cbc63a23b (diff) |
Merge branch 'release/debian/1_5.3.0GA-1'debian/1_5.3.0GA-1
Diffstat (limited to 'app/bin/dcmpnd.c')
-rw-r--r-- | app/bin/dcmpnd.c | 342 |
1 files changed, 194 insertions, 148 deletions
diff --git a/app/bin/dcmpnd.c b/app/bin/dcmpnd.c index 93e73ac..9b7dfcc 100644 --- a/app/bin/dcmpnd.c +++ b/app/bin/dcmpnd.c @@ -17,23 +17,19 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <ctype.h> -#include <string.h> - #include "compound.h" #include "cundo.h" #include "custom.h" #include "fileio.h" -#include "i18n.h" -#include "messages.h" #include "param.h" #include "include/paramfile.h" #include "shrtpath.h" #include "track.h" -#include "utility.h" +#include "trkendpt.h" +#include "common-ui.h" /***************************************************************************** * @@ -47,11 +43,11 @@ 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; + 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 ) @@ -68,30 +64,35 @@ static paramData_t updateTitlePLs[] = { { 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, (void*)400, NULL, BO_READONLY }, + { 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, (void*)400 }, - { PD_BUTTON, (void*)UpdateTitleIgnore, "ignore", PDO_DLGCMDBUTTON, NULL, N_("Ignore") }, + { 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, sizeof updateTitlePLs/sizeof updateTitlePLs[0] }; + { 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 ) + 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 ); + 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; } @@ -102,7 +103,7 @@ static void UpdateTitleNext( void ) wIndex_t inx; wIndex_t cnt; track_p trk; - struct extraData *xx; + struct extraDataCompound_t *xx; updateTitleInx++; if (updateTitleInx >= updateTitles_da.cnt) { wHide( updateTitleW ); @@ -112,11 +113,12 @@ static void UpdateTitleNext( void ) trk = NULL; while (TrackIterate( &trk ) ) { InfoCount(cnt++); - if (GetTrkType(trk) == T_TURNOUT || GetTrkType(trk) == T_STRUCTURE) { - xx = GetTrkExtraData(trk); + 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 ) { + strcmp( xx->title, updateTitles(inx).old ) == 0 ) { xx->title = MyStrdup( updateTitles(inx).new ); break; } @@ -126,14 +128,15 @@ static void UpdateTitleNext( void ) DYNARR_RESET( updateTitleElement, updateTitles_da ); InfoMessage(""); InfoCount( trackCount ); - changed++; - SetWindowTitle(); + SetFileChanged(); DoChangeNotification( CHANGE_MAIN ); return; } - ParamLoadMessage( &updateTitlePG, I_UPDATESTR, updateTitles(updateTitleInx).old ); - if (updateWStale || updateTitles(updateTitleInx).type != updateListType) + ParamLoadMessage( &updateTitlePG, I_UPDATESTR, + updateTitles(updateTitleInx).old ); + if (updateWStale || updateTitles(updateTitleInx).type != updateListType) { UpdateTitleChange( CHANGE_SCALE|CHANGE_PARAMS ); + } } @@ -165,12 +168,15 @@ static void UpdateTitleCancel( wWin_p junk ) void DoUpdateTitles( void ) { - if (updateTitles_da.cnt <= 0) + if (updateTitles_da.cnt <= 0) { return; + } if (updateTitleW == NULL) { ParamRegister( &updateTitlePG ); - updateTitlePLs[I_UPDATELOAD].valueP = (void*)ParamFilesInit(); - updateTitleW = ParamCreateDialog( &updateTitlePG, MakeWindowTitle(_("Update Title")), _("Update"), UpdateTitleUpdate, UpdateTitleCancel, TRUE, NULL, 0, NULL ); + updateTitlePLs[I_UPDATELOAD].valueP = ParamFilesInit(); + updateTitleW = ParamCreateDialog( &updateTitlePG, + MakeWindowTitle(_("Update Title")), _("Update"), UpdateTitleUpdate, + UpdateTitleCancel, TRUE, NULL, 0, NULL ); RegisterChangeNotification( UpdateTitleChange ); } updateTitleInx = -1; @@ -181,13 +187,14 @@ void DoUpdateTitles( void ) } EXPORT void UpdateTitleMark( - char * title, - SCALEINX_T scale ) + char * title, + SCALEINX_T scale ) { int inx; updateTitleElement * ut; - if ( inPlayback ) + if ( inPlayback ) { return; + } for (inx=0; inx<updateTitles_da.cnt; inx++) { if (strcmp(title,updateTitles(inx).old) == 0) { return; @@ -195,10 +202,11 @@ EXPORT void UpdateTitleMark( } DYNARR_APPEND( updateTitleElement, updateTitles_da, 10 ); ut = &updateTitles(updateTitles_da.cnt-1); - if ( tempEndPts_da.cnt > 0) + if ( TempEndPtsCount() > 0) { ut->type = updateTurnout; - else + } else { ut->type = updateStructure; + } ut->scale = scale; ut->old = MyStrdup(title); ut->new = NULL; @@ -211,14 +219,15 @@ EXPORT void UpdateTitleMark( */ static BOOL_T CheckCompoundEndPoint( - track_p trk, - EPINX_T trkEp, - turnoutInfo_t * to, - EPINX_T toEp, - BOOL_T flip ) + track_p trk, + EPINX_T trkEp, + turnoutInfo_t * to, + EPINX_T toEp, + BOOL_T flip ) { - - struct extraData *xx = GetTrkExtraData(trk); + + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_TURNOUT, + extraDataCompound_t); coOrd pos; DIST_T d; ANGLE_T a, a2; @@ -226,20 +235,24 @@ static BOOL_T CheckCompoundEndPoint( Rotate( &pos, xx->orig, -xx->angle ); pos.x -= xx->orig.x; pos.y -= xx->orig.y; - if ( flip ) + if ( flip ) { pos.y = - pos.y; - d = FindDistance( pos, to->endPt[toEp].pos ); + } + d = FindDistance( pos, GetEndPtPos(EndPtIndex(to->endPt,toEp))); if ( d > connectDistance ) { - sprintf( message, _("End-Point #%d of the selected and actual turnouts are not close"), toEp ); + sprintf( message, + _("End-Point #%d of the selected and actual turnouts are not close"), toEp ); return FALSE; } a = GetTrkEndAngle( trk, trkEp ); - a2 = to->endPt[toEp].angle; - if ( flip ) + a2 = GetEndPtAngle(EndPtIndex(to->endPt,toEp)); + if ( flip ) { a2 = 180.0 - a2; + } a = NormalizeAngle( a - xx->angle - a2 + connectAngle/2.0 ); if ( a > connectAngle ) { - sprintf( message, _("End-Point #%d of the selected and actual turnouts are not aligned"), toEp ); + sprintf( message, + _("End-Point #%d of the selected and actual turnouts are not aligned"), toEp ); return FALSE; } return TRUE; @@ -248,17 +261,17 @@ static BOOL_T CheckCompoundEndPoint( int refreshCompoundCnt; static BOOL_T RefreshCompound1( - track_p trk, - turnoutInfo_t * to ) + track_p trk, + turnoutInfo_t * to ) { - struct extraData *xx = GetTrkExtraData(trk); EPINX_T ep, epCnt; BOOL_T ok; BOOL_T flip = FALSE; epCnt = GetTrkEndPtCnt(trk); if ( epCnt != to->endCnt ) { - strcpy( message, _("The selected Turnout had a differing number of End-Points") ); + strcpy( message, + _("The selected Turnout had a differing number of End-Points") ); return FALSE; } ok = TRUE; @@ -269,35 +282,36 @@ static BOOL_T RefreshCompound1( } if ( !ok ) { if ( ep > 0 && epCnt == 2 && - CheckCompoundEndPoint( trk, 1, to, 1, TRUE ) ) { + CheckCompoundEndPoint( trk, 1, to, 1, TRUE ) ) { flip = TRUE; ok = TRUE; } else if ( ep > 0 && epCnt == 3 && - CheckCompoundEndPoint( trk, 1, to, 2, FALSE ) && - CheckCompoundEndPoint( trk, 2, to, 1, FALSE ) ) { + CheckCompoundEndPoint( trk, 1, to, 2, FALSE ) && + CheckCompoundEndPoint( trk, 2, to, 1, FALSE ) ) { ok = TRUE; } else if ( ep > 0 && epCnt == 4 && - CheckCompoundEndPoint( trk, 1, to, 3, FALSE ) && - CheckCompoundEndPoint( trk, 2, to, 2, FALSE ) && - CheckCompoundEndPoint( trk, 3, to, 1, FALSE ) ) { + CheckCompoundEndPoint( trk, 1, to, 3, FALSE ) && + CheckCompoundEndPoint( trk, 2, to, 2, FALSE ) && + CheckCompoundEndPoint( trk, 3, to, 1, FALSE ) ) { ok = TRUE; } else { return FALSE; } } UndoModify( trk ); + struct extraDataCompound_t *xx = GET_EXTRA_DATA(trk, T_NOTRACK, + extraDataCompound_t); FreeFilledDraw( xx->segCnt, xx->segs ); MyFree( xx->segs ); xx->segCnt = to->segCnt; xx->segs = (trkSeg_p)MyMalloc( xx->segCnt * sizeof *(trkSeg_p)0 ); memcpy( xx->segs, to->segs, xx->segCnt * sizeof *(trkSeg_p)0 ); - MyFree( xx->paths); - xx->paths = (signed char*)MyMalloc( to->pathLen * sizeof *xx->paths ); - memcpy( xx->paths, to->paths, to->pathLen * sizeof *xx->paths ); - xx->pathLen = to->pathLen; - xx->pathCurr = xx->paths; - if ( flip ) + xx->pathOverRide = to->pathOverRide; + xx->pathNoCombine = to->pathNoCombine; + SetPaths( trk, GetParamPaths(to) ); + if ( flip ) { FlipSegs( xx->segCnt, xx->segs, zero, 90.0 ); + } ClrTrkBits( trk, TB_SELECTED ); refreshCompoundCnt++; CloneFilledDraw( xx->segCnt, xx->segs, FALSE ); @@ -306,51 +320,52 @@ static BOOL_T RefreshCompound1( typedef struct { - char * name; - turnoutInfo_t * to; - } refreshSpecial_t; + char * name; + turnoutInfo_t * to; +} refreshSpecial_t; static dynArr_t refreshSpecial_da; #define refreshSpecial(N) DYNARR_N( refreshSpecial_t, refreshSpecial_da, N ) static wIndex_t refreshSpecialInx; static BOOL_T refreshReturnVal; -static void RefreshSkip( void * ); +static void RefreshSkip( void * junk ); static paramListData_t refreshSpecialListData = { 30, 600, 0, NULL, NULL }; static paramData_t refreshSpecialPLs[] = { #define REFRESH_M1 (0) - { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, (void*)380 }, + { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, #define REFRESH_M2 (1) - { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, (void*)380 }, + { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, I2VP(380) }, #define REFRESH_S (2) - { PD_MESSAGE, NULL, NULL, 0/*PDO_DLGRESIZEW*/, (void*)380 }, + { 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, (void*)RefreshSkip, "skip", PDO_DLGCMDBUTTON, NULL, N_("Skip") } }; -static paramGroup_t refreshSpecialPG = { "refreshSpecial", 0, refreshSpecialPLs, sizeof refreshSpecialPLs/sizeof refreshSpecialPLs[0] }; + { PD_LIST, &refreshSpecialInx, "list", PDO_LISTINDEX|PDO_NOPREF|PDO_DLGRESIZE, &refreshSpecialListData, NULL, BO_READONLY }, + { PD_BUTTON, RefreshSkip, "skip", PDO_DLGCMDBUTTON, NULL, N_("Skip") } +}; +static paramGroup_t refreshSpecialPG = { "refreshSpecial", 0, refreshSpecialPLs, COUNT( refreshSpecialPLs ) }; static void RefreshSpecialOk( - void * junk ) + void * junk ) { wHide( refreshSpecialPG.win ); } static void RefreshSpecialCancel( - wWin_p win ) + wWin_p win ) { refreshSpecialInx = -1; refreshReturnVal = FALSE; wHide( refreshSpecialPG.win ); } static void RefreshSkip( - void * junk ) + void * junk ) { refreshSpecialInx = -1; wHide( refreshSpecialPG.win ); } EXPORT BOOL_T RefreshCompound( - track_p trk, - BOOL_T junk ) + track_p trk, + BOOL_T junk ) { TRKTYP_T trkType; - struct extraData *xx; + struct extraDataCompound_t *xx; int inx; turnoutInfo_t *to; SCALEINX_T scale; @@ -360,27 +375,29 @@ EXPORT BOOL_T RefreshCompound( refreshCompoundCnt = 0; for ( inx=0; inx<refreshSpecial_da.cnt; inx++ ) if ( refreshSpecial(inx).name != NULL && - refreshSpecial(inx).to == NULL ) + refreshSpecial(inx).to == NULL ) { refreshSpecial(inx).name = NULL; + } return FALSE; } trkType = GetTrkType(trk); - xx = GetTrkExtraData(trk); scale = GetTrkScale(trk); if ( trkType != T_TURNOUT && trkType != T_STRUCTURE ) { ClrTrkBits( trk, TB_SELECTED ); return TRUE; } + xx = GET_EXTRA_DATA(trk, trkType, extraDataCompound_t); refreshReturnVal = TRUE; for ( inx=0; inx<refreshSpecial_da.cnt; inx++ ) { if ( refreshSpecial(inx).name != NULL && - strcasecmp( xx->title, refreshSpecial(inx).name ) == 0 ) { + strcasecmp( xx->title, refreshSpecial(inx).name ) == 0 ) { to = refreshSpecial(inx).to; - if ( to == NULL ) + if ( to == NULL ) { return TRUE; + } if ( IsParamValid(to->paramFileIndex) && - to->segCnt > 0 && - CompatibleScale( GetTrkEndPtCnt(trk)>0, to->scaleInx, scale ) ) { + to->segCnt > 0 && + (FIT_NONE != CompatibleScale( GetTrkEndPtCnt(trk)>0, to->scaleInx, scale ) )) { if ( RefreshCompound1( trk, refreshSpecial(inx).to ) ) { if ( strcasecmp( xx->title, to->title ) != 0 ) { MyFree( xx->title ); @@ -391,24 +408,32 @@ EXPORT BOOL_T RefreshCompound( } } } - if ( ( to = FindCompound( FIND_TURNOUT|FIND_STRUCT, NULL, xx->title ) ) != NULL && - RefreshCompound1( trk, to ) ) + if ( ( to = FindCompound( FIND_TURNOUT|FIND_STRUCT, NULL, xx->title ) ) != NULL + && + RefreshCompound1( trk, to ) ) { return TRUE; + } if ( refreshSpecialPG.win == NULL ) { ParamRegister( &refreshSpecialPG ); - ParamCreateDialog( &refreshSpecialPG, MakeWindowTitle(_("Refresh Turnout/Structure")), _("Ok"), RefreshSpecialOk, RefreshSpecialCancel, TRUE, NULL, F_BLOCK|F_RESIZE|F_RECALLSIZE, NULL ); + ParamCreateDialog( &refreshSpecialPG, + MakeWindowTitle(_("Refresh Turnout/Structure")), _("Ok"), RefreshSpecialOk, + RefreshSpecialCancel, TRUE, NULL, F_BLOCK|F_RESIZE|F_RECALLSIZE, NULL ); } - ParamLoadMessage( &refreshSpecialPG, REFRESH_M1, _("Choose a Turnout/Structure to replace:") ); + ParamLoadMessage( &refreshSpecialPG, REFRESH_M1, + _("Choose a Turnout/Structure to replace:") ); ParamLoadMessage( &refreshSpecialPG, REFRESH_M2, "" ); refreshSpecialInx = -1; wListClear( (wList_p)refreshSpecialPLs[REFRESH_L].control ); - if ( GetTrkEndPtCnt(trk) > 0 ) - to = TurnoutAdd( listLabels, scale, (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL, GetTrkEndPtCnt(trk) ); - else - to = StructAdd( listLabels, scale, (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL ); + if ( GetTrkEndPtCnt(trk) > 0 ) { + to = TurnoutAdd( listLabels, scale, + (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL, GetTrkEndPtCnt(trk) ); + } else { + to = StructAdd( listLabels, scale, + (wList_p)refreshSpecialPLs[REFRESH_L].control, NULL ); + } if ( to == NULL ) { NoticeMessage( MSG_NO_TURNOUTS_AVAILABLE, _("Ok"), NULL, - GetTrkEndPtCnt(trk)>0 ? _("Turnouts") : _("Structures") ); + GetTrkEndPtCnt(trk)>0 ? _("Turnouts") : _("Structures") ); return FALSE; } FormatCompoundTitle( listLabels, xx->title ); @@ -424,9 +449,10 @@ EXPORT BOOL_T RefreshCompound( } return refreshReturnVal; } - to = (turnoutInfo_t*)wListGetItemContext( (wList_p)refreshSpecialPLs[REFRESH_L].control, refreshSpecialInx ); + to = (turnoutInfo_t*)wListGetItemContext( (wList_p) + refreshSpecialPLs[REFRESH_L].control, refreshSpecialInx ); if ( to != NULL && - RefreshCompound1( trk, to ) ) { + RefreshCompound1( trk, to ) ) { DYNARR_APPEND( refreshSpecial_t, refreshSpecial_da, 10 ); refreshSpecial(refreshSpecial_da.cnt-1).to = to; refreshSpecial(refreshSpecial_da.cnt-1).name = MyStrdup( xx->title ); @@ -437,7 +463,8 @@ EXPORT BOOL_T RefreshCompound( return TRUE; } ParamLoadMessage( &refreshSpecialPG, REFRESH_M1, message ); - ParamLoadMessage( &refreshSpecialPG, REFRESH_M2, _("Choose another Turnout/Structure to replace:") ); + ParamLoadMessage( &refreshSpecialPG, REFRESH_M2, + _("Choose another Turnout/Structure to replace:") ); } } @@ -453,14 +480,15 @@ static char renamePartno[STR_SIZE]; static turnoutInfo_t * renameTo; static paramData_t renamePLs[] = { -/*0*/ { PD_STRING, renameManuf, "manuf", PDO_NOPREF | PDO_STRINGLIMITLENGTH, (void*)350, N_("Manufacturer"), 0, 0, sizeof(renameManuf)}, -/*1*/ { PD_STRING, renameDesc, "desc", PDO_NOPREF | PDO_STRINGLIMITLENGTH, (void*)230, N_("Description"), 0, 0, sizeof(renameDesc)}, -/*2*/ { PD_STRING, renamePartno, "partno", PDO_NOPREF|PDO_DLGHORZ|PDO_DLGIGNORELABELWIDTH | PDO_STRINGLIMITLENGTH, (void*)100, N_("#"), 0, 0, sizeof(renamePartno)} }; -static paramGroup_t renamePG = { "rename", 0, renamePLs, sizeof renamePLs/sizeof renamePLs[0] }; + /*0*/ { PD_STRING, renameManuf, "manuf", PDO_NOPREF | PDO_NOTBLANK, I2VP(350), N_("Manufacturer"), 0, 0, sizeof(renameManuf)}, + /*1*/ { PD_STRING, renameDesc, "desc", PDO_NOPREF | PDO_NOTBLANK, I2VP(230), N_("Description"), 0, 0, sizeof(renameDesc)}, + /*2*/ { PD_STRING, renamePartno, "partno", PDO_NOPREF|PDO_DLGHORZ|PDO_DLGIGNORELABELWIDTH | PDO_NOTBLANK, I2VP(100), N_("#"), 0, 0, sizeof(renamePartno)} +}; +static paramGroup_t renamePG = { "rename", 0, renamePLs, COUNT( renamePLs ) }; EXPORT BOOL_T CompoundCustomSave( - FILE * f ) + FILE * f ) { int inx; turnoutInfo_t * to; @@ -469,19 +497,24 @@ EXPORT BOOL_T CompoundCustomSave( for ( inx=0; inx<turnoutInfo_da.cnt; inx++ ) { to = turnoutInfo(inx); if (to->paramFileIndex == PARAM_CUSTOM && to->segCnt > 0) { - rc &= fprintf( f, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( f, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( f, "\tU %s\n",to->customInfo )>0; - rc &= WriteCompoundPathsEndPtsSegs( f, to->paths, to->segCnt, to->segs, - to->endCnt, to->endPt ); + } + rc &= WriteCompoundPathsEndPtsSegs( f, GetParamPaths( to ), to->segCnt, + to->segs, + to->endCnt, to->endPt ); } } for ( inx=0; inx<structureInfo_da.cnt; inx++ ) { to = structureInfo(inx); if (to->paramFileIndex == PARAM_CUSTOM && to->segCnt > 0) { - rc &= fprintf( f, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( f, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( f, "\tU %s\n",to->customInfo )>0; + } rc &= WriteSegs( f, to->segCnt, to->segs ); } } @@ -492,8 +525,9 @@ EXPORT BOOL_T CompoundCustomSave( static void RenameOk( void * junk ) { sprintf( message, "%s\t%s\t%s", renameManuf, renameDesc, renamePartno ); - if ( renameTo->title ) + if ( renameTo->title ) { MyFree( renameTo->title ); + } renameTo->title = MyStrdup( message ); wHide( renamePG.win ); DoChangeNotification( CHANGE_PARAMS ); @@ -501,8 +535,8 @@ static void RenameOk( void * junk ) static int CompoundCustMgmProc( - int cmd, - void * data ) + int cmd, + void * data ) { turnoutInfo_t * to = (turnoutInfo_t*)data; turnoutInfo_t * to2=NULL; @@ -513,18 +547,24 @@ static int CompoundCustMgmProc( switch ( cmd ) { case CUSTMGM_DO_COPYTO: - if ( to->segCnt <= 0 ) + if ( to->segCnt <= 0 ) { return TRUE; + } if ( to->endCnt ) { - rc &= fprintf( customMgmF, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( customMgmF, "TURNOUT %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( customMgmF, "\tU %s\n",to->customInfo )>0; - rc &= WriteCompoundPathsEndPtsSegs( customMgmF, to->paths, to->segCnt, to->segs, - to->endCnt, to->endPt ); + } + rc &= WriteCompoundPathsEndPtsSegs( customMgmF, + GetParamPaths( to ), to->segCnt, to->segs, + to->endCnt, to->endPt ); } else { - rc &= fprintf( customMgmF, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), PutTitle(to->title) )>0; - if ( to->customInfo ) + rc &= fprintf( customMgmF, "STRUCTURE %s \"%s\"\n", GetScaleName(to->scaleInx), + PutTitle(to->title) )>0; + if ( to->customInfo ) { rc &= fprintf( customMgmF, "\tU %s\n",to->customInfo )>0; + } rc &= WriteSegs( customMgmF, to->segCnt, to->segs ); } return rc; @@ -539,23 +579,24 @@ static int CompoundCustMgmProc( strncpy( renamePartno, nP, nL ); renamePartno[nL] = 0; if ( !renamePG.win ) { ParamRegister( &renamePG ); - ParamCreateDialog( &renamePG, MakeWindowTitle(_("Rename Object")), _("Ok"), RenameOk, wHide, TRUE, NULL, F_BLOCK, NULL ); + ParamCreateDialog( &renamePG, MakeWindowTitle(_("Rename Object")), _("Ok"), + RenameOk, wHide, TRUE, NULL, F_BLOCK, NULL ); } ParamLoadControls( &renamePG ); wShow( renamePG.win ); } else { - for (inx=0; inx<turnoutInfo_da.cnt && to!=turnoutInfo(inx); inx++); - if ( inx > 0 && - turnoutInfo(inx-1)->customInfo && - strcmp( to->customInfo, turnoutInfo(inx-1)->customInfo ) == 0 ) { - to2 = to; - to = turnoutInfo(inx-1); - } else if ( inx < turnoutInfo_da.cnt-1 && - turnoutInfo(inx+1)->customInfo && - strcmp( to->customInfo, turnoutInfo(inx+1)->customInfo ) == 0 ) { - to2 = turnoutInfo(inx+1); - } - EditCustomTurnout( to, to2 ); + for (inx=0; inx<turnoutInfo_da.cnt && to!=turnoutInfo(inx); inx++); + if ( inx > 0 && + turnoutInfo(inx-1)->customInfo && + strcmp( to->customInfo, turnoutInfo(inx-1)->customInfo ) == 0 ) { + to2 = to; + to = turnoutInfo(inx-1); + } else if ( inx < turnoutInfo_da.cnt-1 && + turnoutInfo(inx+1)->customInfo && + strcmp( to->customInfo, turnoutInfo(inx+1)->customInfo ) == 0 ) { + to2 = turnoutInfo(inx+1); + } + EditCustomTurnout( to, to2 ); } return TRUE; case CUSTMGM_CAN_DELETE: @@ -565,15 +606,16 @@ static int CompoundCustMgmProc( return TRUE; case CUSTMGM_GET_TITLE: ParseCompoundTitle( to->title, &mP, &mL, &pP, &pL, &nP, &nL ); - sprintf( message, "\t%.*s\t%s\t%.*s\t%.*s", mL, mP, GetScaleName(to->scaleInx), nL, nP, pL, pP ); + sprintf( message, "\t%.*s\t%s\t%.*s\t%.*s", mL, mP, GetScaleName(to->scaleInx), + nL, nP, pL, pP ); return TRUE; } return FALSE; } -#include "bitmaps/turnout.xpm" -#include "bitmaps/struct.xpm" +#include "bitmaps/turnout.xpm3" +#include "bitmaps/building.xpm3" EXPORT void CompoundCustMgmLoad( void ) { @@ -582,21 +624,23 @@ EXPORT void CompoundCustMgmLoad( void ) static wIcon_p turnoutI = NULL; static wIcon_p structI = NULL; - if ( turnoutI == NULL ) - turnoutI = wIconCreatePixMap( turnout_xpm ); - if ( structI == NULL ) - structI = wIconCreatePixMap( struct_xpm ); + if ( turnoutI == NULL ) { + turnoutI = wIconCreatePixMap( turnout_xpm3[0] ); + } + if ( structI == NULL ) { + structI = wIconCreatePixMap( building_xpm3[0] ); + } for ( inx=0; inx<turnoutInfo_da.cnt; inx++ ) { to = turnoutInfo(inx); if (to->paramFileIndex == PARAM_CUSTOM && to->segCnt > 0) { - CustMgmLoad( turnoutI, CompoundCustMgmProc, (void*)to ); + CustMgmLoad( turnoutI, CompoundCustMgmProc, to ); } } for ( inx=0; inx<structureInfo_da.cnt; inx++ ) { to = structureInfo(inx); if (to->paramFileIndex == PARAM_CUSTOM && to->segCnt > 0) { - CustMgmLoad( structI, CompoundCustMgmProc, (void*)to ); + CustMgmLoad( structI, CompoundCustMgmProc, to ); } } } @@ -608,13 +652,15 @@ EXPORT void CompoundCustMgmLoad( void ) */ wIndex_t FindListItemByContext( - wList_p listP, - void * context ) + wList_p listP, + void * context ) { - if ( listP == NULL ) + if ( listP == NULL ) { return -1; - if ( context == NULL ) + } + if ( context == NULL ) { return -1; + } for ( wIndex_t inx = 0; inx < wListGetCount( listP ); ++inx ) { void * itemContext = wListGetItemContext( listP, inx ); if ( itemContext != NULL ) { |