Skip to content

Commit

Permalink
Merge pull request #230 from risvh/20311
Browse files Browse the repository at this point in the history
v20311
  • Loading branch information
risvh authored Mar 1, 2024
2 parents fd70709 + 4feef8c commit c6cc97c
Show file tree
Hide file tree
Showing 35 changed files with 3,942 additions and 372 deletions.
27 changes: 27 additions & 0 deletions documentation/devProcess/monitorResolutionTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Find modeline with:

gtf 1280 720 60


Add mode:

xrandr --newmode "1280x720_60.00" 74.48 1280 1336 1472 1664 720 721 724 746 -HSync +Vsync


Add mode to monitor:

xrandr --addmode eDP-1 "1280x720_60.00"



NOTE: this seems to cause a problem.
Disable stretching:

xrandr --output eDP-1 --set "scaling mode" "Full aspect"




Switch to mode using monitor control panel


27 changes: 27 additions & 0 deletions gameSource/EditorCategoryPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ EditorCategoryPage::EditorCategoryPage()
addKeyClassDescription( &mKeyLegend, "Pg Up/Down", "Change order" );
addKeyClassDescription( &mKeyLegend, "Ctr/Shft", "Bigger jumps" );
addKeyClassDescription( &mKeyLegend, "Bkspce", "Remv item" );
addKeyDescription( &mKeyLegend, 'c', "Copy CSV to clipboard" );

addKeyDescription( &mKeyLegendPattern, 'd', "Duplicate item in place" );
addKeyDescription( &mKeyLegendPattern, 'D', "Duplicate item to bottom" );
Expand Down Expand Up @@ -703,6 +704,32 @@ void EditorCategoryPage::keyDown( unsigned char inASCII ) {
updateCheckbox();
}
}

if( inASCII == 'c' && mCurrentCategory != -1 ) {
CategoryRecord *cat = getCategory( mCurrentCategory );

if( cat != NULL ) {

SimpleVector<char> workingCSV;


for( int i=0; i< cat->objectIDSet.size(); i++ ) {
int id = cat->objectIDSet.getElementDirect( i );

ObjectRecord *o = getObject( id );

workingCSV.appendElementString( "\"" );
workingCSV.appendElementString( o->description );
workingCSV.appendElementString( "\"\n" );
}

char *csvText = workingCSV.getElementString();

setClipboardText( csvText );

delete [] csvText;
}
}
}


Expand Down
169 changes: 109 additions & 60 deletions gameSource/EditorScenePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ EditorScenePage::EditorScenePage()
mReplaceButton( smallFont, -500, 260, "Replace" ),
mDeleteButton( smallFont, 500, 260, "Delete" ),
mSaveTestMapButton( smallFont, -300, 200, "Export Test Map" ),
mLoadTestMapButton( smallFont, -500, 200, "Import Test Map" ),
mNextSceneButton( smallFont, -420, 260, ">" ),
mPrevSceneButton( smallFont, -580, 260, "<" ),
mClearSceneButton( smallFont, 350, 260, "Clear" ),
Expand Down Expand Up @@ -152,6 +153,16 @@ EditorScenePage::EditorScenePage()
addComponent( &mSaveTestMapButton );
mSaveTestMapButton.addActionListener( this );

addComponent( &mLoadTestMapButton );
mLoadTestMapButton.addActionListener( this );

File *testSceneFile = new File( NULL, "testMapScene.txt" );

mLoadTestMapButton.setVisible( testSceneFile->exists() );

delete testSceneFile;



addComponent( &mNextSceneButton );
mNextSceneButton.addActionListener( this );
Expand Down Expand Up @@ -478,6 +489,16 @@ void EditorScenePage::actionPerformed( GUIComponent *inTarget ) {
checkNextPrevVisible();
}
else if( inTarget == &mSaveTestMapButton ) {
// save as scene file too, for easy re-loading later
File *sceneFile = new File( NULL, "testMapScene.txt" );

writeSceneToFile( sceneFile );

delete sceneFile;

mLoadTestMapButton.setVisible( true );


FILE *f = fopen( "testMap.txt", "w" );

if( f != NULL ) {
Expand Down Expand Up @@ -521,6 +542,18 @@ void EditorScenePage::actionPerformed( GUIComponent *inTarget ) {
fclose( f );
}
}
else if( inTarget == &mLoadTestMapButton ) {
// just re-load our saved test scene file
File *sceneFile = new File( NULL, "testMapScene.txt" );

char r = tryLoadScene( sceneFile );

delete sceneFile;

if( !r ) {
printf( "Failed to load scene from testMapScene.txt\n" );
}
}
else if( inTarget == &mReplaceButton ) {
writeSceneToFile( mSceneID );
}
Expand Down Expand Up @@ -2619,6 +2652,15 @@ void addCellLines( SimpleVector<char*> *inLines,

void EditorScenePage::writeSceneToFile( int inIDToUse ) {
File *f = getSceneFile( inIDToUse );

writeSceneToFile( f );

delete f;
}



void EditorScenePage::writeSceneToFile( File *inFile ) {

SimpleVector<char*> lines;

Expand Down Expand Up @@ -2659,10 +2701,8 @@ void EditorScenePage::writeSceneToFile( int inIDToUse ) {
delete [] linesArray;
lines.deallocateStringElements();

f->writeToFile( contents );
inFile->writeToFile( contents );
delete [] contents;

delete f;
}


Expand Down Expand Up @@ -2835,89 +2875,98 @@ char EditorScenePage::tryLoadScene( int inSceneID ) {
if( f->exists() && ! f->isDirectory() ) {
printf( "Trying to load scene %d\n", inSceneID );

r = tryLoadScene( f );
}

delete f;

return r;
}



char EditorScenePage::tryLoadScene( File *inFile ) {

char r = false;

char *fileText = inFile->readFileContents();

char *fileText = f->readFileContents();

if( fileText != NULL ) {
if( fileText != NULL ) {

int numLines = 0;
int numLines = 0;

char **lines = split( fileText, "\n", &numLines );
delete [] fileText;
char **lines = split( fileText, "\n", &numLines );
delete [] fileText;

int next = 0;
int next = 0;


int w = mSceneW;
int h = mSceneH;
int w = mSceneW;
int h = mSceneH;

sscanf( lines[next], "w=%d", &w );
next++;
sscanf( lines[next], "h=%d", &h );
next++;
sscanf( lines[next], "w=%d", &w );
next++;
sscanf( lines[next], "h=%d", &h );
next++;

if( w != mSceneW || h != mSceneH ) {
resizeGrid( h, w );
}
if( w != mSceneW || h != mSceneH ) {
resizeGrid( h, w );
}

if( strstr( lines[next], "origin" ) != NULL ) {
sscanf( lines[next], "origin=%d,%d", &mZeroX, &mZeroY );
next++;
}
if( strstr( lines[next], "origin" ) != NULL ) {
sscanf( lines[next], "origin=%d,%d", &mZeroX, &mZeroY );
next++;
}

char floorPresent = false;
char floorPresent = false;

if( strstr( lines[next], "floorPresent" ) != NULL ) {
floorPresent = true;
next++;
}
if( strstr( lines[next], "floorPresent" ) != NULL ) {
floorPresent = true;
next++;
}


clearScene();
clearScene();

int numRead = 0;
int numRead = 0;

int x, y;
int x, y;

numRead = sscanf( lines[next], "x=%d,y=%d", &x, &y );
next++;
numRead = sscanf( lines[next], "x=%d,y=%d", &x, &y );
next++;

while( numRead == 2 ) {
SceneCell *c = &( mCells[y][x] );
SceneCell *p = &( mPersonCells[y][x] );
SceneCell *f = &( mFloorCells[y][x] );
while( numRead == 2 ) {
SceneCell *c = &( mCells[y][x] );
SceneCell *p = &( mPersonCells[y][x] );
SceneCell *f = &( mFloorCells[y][x] );

next = scanCell( lines, next, c );
next = scanCell( lines, next, p );
next = scanCell( lines, next, c );
next = scanCell( lines, next, p );

if( floorPresent ) {
next = scanCell( lines, next, f );
}
if( floorPresent ) {
next = scanCell( lines, next, f );
}

numRead = 0;
numRead = 0;

if( next < numLines ) {
numRead = sscanf( lines[next], "x=%d,y=%d", &x, &y );
next++;
}
if( next < numLines ) {
numRead = sscanf( lines[next], "x=%d,y=%d", &x, &y );
next++;
}
}

for( int i=0; i<numLines; i++ ) {
delete [] lines[i];
}
delete [] lines;

r = true;
mCurX = mZeroX;
mCurY = mZeroY;
mShiftX = 0;
mShiftY = 0;
for( int i=0; i<numLines; i++ ) {
delete [] lines[i];
}
delete [] lines;

r = true;
mCurX = mZeroX;
mCurY = mZeroY;
mShiftX = 0;
mShiftY = 0;
}


delete f;

return r;
}

Expand Down
5 changes: 5 additions & 0 deletions gameSource/EditorScenePage.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class EditorScenePage : public GamePage, public ActionListener {
TextButton mDeleteButton;

TextButton mSaveTestMapButton;
TextButton mLoadTestMapButton;

TextButton mNextSceneButton;
TextButton mPrevSceneButton;
Expand Down Expand Up @@ -220,8 +221,12 @@ class EditorScenePage : public GamePage, public ActionListener {
File *getSceneFile( int inSceneID );

char tryLoadScene( int inSceneID );

char tryLoadScene( File *inFile );

void writeSceneToFile( int inIDToUse );

void writeSceneToFile( File *inFile );

void checkNextPrevVisible();

Expand Down
6 changes: 3 additions & 3 deletions gameSource/EditorTransitionPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,19 +1199,19 @@ void EditorTransitionPage::draw( doublePair inViewCenter,

if( mProducesType[i] == 1 ) {
setDrawColor( 1, 1, 0.5, 1 );
noteString = "From Category:";
noteString = "From Category ^";
}
else if( mProducesType[i] == 2 ) {
setDrawColor( 1, 0.75, 0.75, 1 );
noteString = "From Pattern:";
noteString = "From Pattern ^";
}
else {
setDrawColor( 1, 1, 1, 1 );
}

doublePair notePos = pos;
notePos.x -= 48;
notePos.y += 60;
notePos.y -= 60;
smallFont->drawString( noteString,
notePos, alignLeft );

Expand Down
2 changes: 1 addition & 1 deletion gameSource/ExistingAccountPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ void ExistingAccountPage::draw( doublePair inViewCenter,
setStatusDirect( message, true );
delete [] message;
setStatusPositiion( true );
setStatusPosition( true );
mRetryButton.setVisible( true );
mRedetectButton.setVisible( true );
mCancelButton.setVisible( true );
Expand Down
2 changes: 1 addition & 1 deletion gameSource/GamePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void GamePage::setTipPosition( char inTop ) {
}


void GamePage::setStatusPositiion( char inTop ) {
void GamePage::setStatusPosition( char inTop ) {
mStatusAtTopOfScreen = inTop;
}

Expand Down
2 changes: 1 addition & 1 deletion gameSource/GamePage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GamePage : public PageComponent {

// overrides default status position
// status messages default to bottom of screen
void setStatusPositiion( char inTop );
void setStatusPosition( char inTop );


// override these from PageComponent to actually SHOW
Expand Down
Loading

0 comments on commit c6cc97c

Please sign in to comment.