Skip to content

Commit

Permalink
update to OpenRCT2 v0.4.11, improved pause game detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Die4Ever committed May 5, 2024
1 parent 3836ad8 commit b3647a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
18 changes: 5 additions & 13 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,11 @@ function runNextTick(func: Function) {
}

function ifPaused(whenPaused: () => void, whenUnpaused: () => void) {
var wasPaused = { wasPaused: undefined };
var oldElapsed = date.ticksElapsed;
context.setTimeout(function() {
if( date.ticksElapsed == oldElapsed ) {
wasPaused.wasPaused = true;
if(whenPaused)
whenPaused();
} else {
wasPaused.wasPaused = false;
if(whenUnpaused)
whenUnpaused();
}
}, 100);
var wasPaused = context.paused;

if(wasPaused) whenPaused();
else whenUnpaused();

return wasPaused;
}

Expand Down
12 changes: 5 additions & 7 deletions src/gui/archipelagoWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ function archipelagoGui(){
archipelago_settings.started = true;
saveArchipelagoProgress();//Save the settings to our Archipelago tracker
// we need to unpause the game in order for the next tick to run
var wasPaused = UnpauseGame();
UnpauseGame();
runNextTick(function() {
initRando();
if(wasPaused.wasPaused && global_settings.auto_pause) {
// we know the game is currently unpaused because we're inside a tick event
// so we don't need the fancy PauseGame function
context.executeAction('pausetoggle', {});
if(global_settings.auto_pause) {
PauseGame();
}
createChangesWindow();
});
Expand Down Expand Up @@ -115,8 +113,8 @@ function archipelagoLocations(){
var Archipelago = GetModule("RCTRArchipelago") as RCTRArchipelago;
var messageLog = context.getParkStorage().get("RCTRando.MessageLog") as Array<any>;

var game_choice = ["Ocarina of Time", "Adventure", "Donkey Kong Country 3", "Final Fantasy 1", "Hollow Knight",
"The Legend of Zelda", "A Link to the Past", "Links Awakening", "Pokemon Red and Blue", "Rogue Legacy",
var game_choice = ["Ocarina of Time", "Adventure", "Donkey Kong Country 3", "Final Fantasy 1", "Hollow Knight",
"The Legend of Zelda", "A Link to the Past", "Links Awakening", "Pokemon Red and Blue", "Rogue Legacy",
"Sonic Adventure 2", "Super Mario World", "Super Mario 64", "Super Metroid", "VVVVVV"];
var game = game_choice[Math.floor(Math.random() * game_choice.length)];//Gotta throw that shade

Expand Down
8 changes: 3 additions & 5 deletions src/gui/newGameWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ function startGameGui() {
settings.num_months_cycle = randoCycles[cycle['text']];

// we need to unpause the game in order for the next tick to run
var wasPaused = UnpauseGame();
UnpauseGame();
runNextTick(function() {
initRando();
if(wasPaused.wasPaused && global_settings.auto_pause) {
// we know the game is currently unpaused because we're inside a tick event
// so we don't need the fancy PauseGame function
context.executeAction('pausetoggle', {});
if(global_settings.auto_pause) {
PauseGame();
}
createChangesWindow();
});
Expand Down
2 changes: 1 addition & 1 deletion src/rctrando_init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let initedMenuItems:boolean = false;
let subscriptions = []

const minApiVersion = 52;// or 60?
const targetApiVersion = 77;// v0.4.5
const targetApiVersion = 84;// v0.4.11
info(" \n"+rando_name+" v"+rando_version
+ ", OpenRCT2 API version "+context.apiVersion+', minimum required API version is '+minApiVersion+', recommended API version is '+targetApiVersion
+ ', network.mode: '+network.mode+', context.mode: '+context.mode
Expand Down

0 comments on commit b3647a5

Please sign in to comment.