Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Commit 23151ac

Browse files
committed
Merge branch 'master' into development
2 parents 6606060 + e5f4dc8 commit 23151ac

17 files changed

+123
-23
lines changed

CLI.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@
3434
parser.add_argument("rom", type=str)
3535
parser.add_argument("--no-extend", default=False, help="disable auto-extend of ROM, which might fail on some systems", action="store_true")
3636
parser.add_argument("--out", type=str, help="target of randomized rom")
37-
parser.add_argument("--seed", type=int, default=round(time.time() * 256 * 1000), help="define a custom seed to have the same experience as someone else")
37+
#parser.add_argument("--seed", type=int, default=round(time.time() * 256 * 1000), help="define a custom seed to have the same experience as someone else")
3838
parser.add_argument('--version', action='version', version=f'v{__version__}')
3939
argument_labels = {
4040
"rom": "Input ROM",
4141
"out": "Output ROM",
4242
"no_extend": "Disable automatic extending",
43-
"seed": "RNG Seed",
4443
}
4544
for field in randomizer_params:
4645
argument_args = []

Constants.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
from Parsers.Level import Level
2+
from pathlib import Path
23
import os
34
import json
5+
import sys
6+
7+
application_path = None
8+
if getattr(sys, 'frozen', False):
9+
application_path = os.path.abspath(os.path.join(sys.executable, os.pardir))
10+
else:
11+
application_path = os.path.dirname(os.path.abspath(__file__))
412

513
LVL_MAIN=Level(0x108A10, 0x108A40, None, "Main Entry")
614
LVL_GAME_OVER=Level(0x269EA0, 0x26A3A0, None, "Game Over")
@@ -249,7 +257,9 @@
249257
SPECIAL_WARP_IDS = [WARP_ID_WIN, WARP_ID_LOSE, WARP_ID_RECOVER]
250258

251259
BEHAVIOUR_NAMES = {}
252-
with open(os.path.join("Data", "behaviorNames.json"), "r") as behavior_file:
260+
261+
application_path
262+
with open(os.path.join(application_path, "Data", "behaviorNames.json"), "r") as behavior_file:
253263
BEHAVIOUR_NAMES = json.loads(behavior_file.read())
254264

255265
BEHAVIOUR_NAMES = dict({ hex(int(key, 16)): name for (key, name) in BEHAVIOUR_NAMES.items()})

Data/configurableParams.json

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
[
2+
{
3+
"name": "seed",
4+
"label": "Random Seed",
5+
"category": "gameplay",
6+
"type": "text",
7+
"help": "Allows you to play the same version as a friend, simply enter the same seed as them and you will be playing the exact same ROM."
8+
},
29
{
310
"name": "shuffle-paintings",
411
"label": "Painting (Art) randomization",

Rom.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def try_extend(self):
110110
if operating_sys == 'Darwin':
111111
subprocess.check_call(['./3rdparty/sm64extend_mac_x64', *args])
112112
elif operating_sys == 'Linux':
113-
subprocess.check_call(['./3rdparty/sm64extend_ubuntu_x64', str(self.out_path)])
113+
subprocess.check_call(['./3rdparty/sm64extend_ubuntu_x64', *args])
114114
elif operating_sys == 'Windows':
115115
subprocess.check_call(['3rdparty/sm64extend_win_x86.exe', *args])
116116
else:

docs/configurableParams.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
configurableParams = [
2+
{
3+
"name": "seed",
4+
"label": "Random Seed",
5+
"category": "gameplay",
6+
"type": "text",
7+
"help": "Allows you to play the same version as a friend, simply enter the same seed as them and you will be playing the exact same ROM."
8+
},
29
{
310
"name": "shuffle-paintings",
411
"label": "Painting (Art) randomization",

docs/css/generator.css

+15
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ section .dropzone .dz-preview .dz-image {
3131
top: 50%;
3232
margin-left: 20px; }
3333

34+
.field--type--text input {
35+
background: none;
36+
border: none;
37+
font-size: large;
38+
border-bottom: 2px solid white;
39+
color: white;
40+
text-align: right; }
41+
3442
.field--type--text label, .field--type--select label, .field--type--file label {
3543
min-width: 200px;
3644
display: inline-block;
@@ -215,3 +223,10 @@ button.help:hover .tooltip-content {
215223
bottom: 0;
216224
transition: 1s ease width;
217225
box-shadow: 0 0 4px white; }
226+
227+
.download-rom {
228+
display: block;
229+
margin: 20px;
230+
color: white;
231+
font-size: larger;
232+
text-shadow: 0 0 2px white; }

docs/generator.html

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<base href="sm64-randomizer" />
1111
<title>Super Mario 64 Randomizer</title>
1212

13+
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
1314
<link href="css/normalize.css" rel="stylesheet">
1415
<link href="css/main.css" rel="stylesheet">
1516
<link href="css/generator.css" rel="stylesheet">

docs/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<meta name="description" content="Super Mario 64 Randomizer - Re-experience the classic game in new challenging ways">
99
<meta name="keywords" content="Super Mario 64, SM64, SM64 Randomizer, Modding, Hacking, SM64 Rando, Super Mario 64 Randomizer">
10-
10+
<base href="sm64-randomizer" />
1111
<title>Super Mario 64 Randomizer</title>
1212

13+
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
1314
<link href="css/normalize.css" rel="stylesheet">
1415
<link href="css/main.css" rel="stylesheet">
1516
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">

docs/js/generator.js

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let BASE_URL = 'http://hannes.fun:5337'
1+
let BASE_URL = 'https://mayro.hannes.fun'
22

33
if (location.hostname == 'localhost' || location.hostname == '127.0.0.1') {
44
BASE_URL = 'http://localhost:5000'
@@ -16,6 +16,10 @@ $(document).ready(() => {
1616
}
1717
const $fields = []
1818
$.each(configurableParams, (_, field) => {
19+
if (field.name == 'seed') {
20+
field.default = Math.round(Math.random() * 1e10).toString()
21+
}
22+
1923
const fieldName = field.name
2024
const categoryName = field.category
2125
$targetCategory = $(`#category-${categoryName}`)
@@ -245,12 +249,19 @@ $(document).ready(() => {
245249
clearInterval(tracking_interval)
246250
tracking_active = false
247251

248-
const link = document.createElement("a")
249-
link.href = BASE_URL + '/download/' + upload_ticket
252+
$downloadLink = $("<a />")
253+
$downloadLink.addClass("download-rom")
254+
$downloadLink.attr("href", BASE_URL + '/download/' + upload_ticket)
250255
const fileNameParts = fileNameSelected.split('.')
251256
const fileExt = fileNameParts[fileNameParts.length - 1]
252-
link.download = 'Super Mario 64 Randomizer ROM' + fileExt
253-
link.click()
257+
$downloadLink.attr("download", 'Super Mario 64 Randomizer ROM' + fileExt)
258+
$downloadLink.text("Download your ROM!")
259+
260+
if ($queueGenerationButton.next().hasClass("download-rom")) {
261+
$queueGenerationButton.next().remove()
262+
}
263+
$($queueGenerationButton).after($downloadLink)
264+
$downloadLink.get(0).click()
254265

255266
// queue-generation-message
256267
$queueGenerationButton.children("span").text("Queue for generation")
@@ -296,10 +307,11 @@ $(document).ready(() => {
296307
label: "ROM Receive failed: " + (errMessage != null ? errMessage : "(Unknown Error)")
297308
})
298309

310+
alert("Unfortunately the server returned an invalid response. Please try again later")
311+
299312
$queueGenerationButton.children("span").text("Queue for generation")
300313
$queueGenerationButton.prop("disabled", false)
301314
$queueGenerationButton.removeClass("indefinite")
302-
alert(error)
303315
return
304316
}
305317
})
@@ -356,6 +368,7 @@ $(document).ready(() => {
356368
e.preventDefault()
357369

358370
if (!$realUpload.val()) {
371+
alert("Please select a ROM that you want to randomize first!")
359372
return
360373
}
361374

@@ -367,6 +380,10 @@ $(document).ready(() => {
367380
formDataBlob.delete("fake-upload")
368381
formDataBlob.set("input_rom", dataBlob, "input_rom.zip")
369382

383+
if ($queueGenerationButton.next().hasClass("download-rom")) {
384+
$queueGenerationButton.next().remove()
385+
}
386+
370387
$queueGenerationButton.prop("disabled", true)
371388
$queueGenerationButton.children('span').text("Uploading...")
372389

docs/legal.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<meta name="description" content="Super Mario 64 Randomizer - Re-experience the classic game in new challenging ways">
99
<meta name="keywords" content="Super Mario 64, SM64, SM64 Randomizer, Modding, Hacking, SM64 Rando, Super Mario 64 Randomizer">
10-
10+
<base href="sm64-randomizer" />
1111
<title>Super Mario 64 Randomizer</title>
1212

13+
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
1314
<link href="css/normalize.css" rel="stylesheet">
1415
<link href="css/main.css" rel="stylesheet">
1516
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">

gui.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from shlex import quote
1818
from random import randint
1919
from CLI import run_with_args
20+
from Constants import application_path
2021
import webbrowser
2122

2223
MAIN_TITLE = f"SM64 Randomizer by @andremeyer93 - v{__version__}"
@@ -323,7 +324,7 @@ def add_setting_field(self, field):
323324
optionFrame.pack(side=TOP, padx=5, pady=(5,1), fill=X)
324325

325326
def add_settings_from_file(self):
326-
with open(os.path.join('Data', 'configurableParams.json')) as json_file:
327+
with open(os.path.join(application_path, 'Data', 'configurableParams.json'), 'r') as json_file:
327328
fields = json.loads(json_file.read())
328329

329330
for field in fields:

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ macholib==1.11
44
numpy==1.16.3
55
pefile==2019.4.18
66
PyInstaller==3.4
7-
pyperclip==1.7.0
7+
pyperclip==1.7.0
8+
wheel==0.33.4

web/assets/js/generator.js

+28-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let BASE_URL = 'http://hannes.fun:5337'
1+
let BASE_URL = 'https://mayro.hannes.fun'
22

33
if (location.hostname == 'localhost' || location.hostname == '127.0.0.1') {
44
BASE_URL = 'http://localhost:5000'
@@ -15,6 +15,15 @@ $(document).ready(() => {
1515
}
1616
}
1717
const $fields = []
18+
configurableParams.unshift({
19+
name: 'seed',
20+
label: "Enter a Seed",
21+
help: "Enter the same seed as your friend, so you two will receive the same version!",
22+
default: Math.round(Math.random() * 1e10).toString(),
23+
category: 'gameplay',
24+
type: 'text'
25+
})
26+
1827
$.each(configurableParams, (_, field) => {
1928
const fieldName = field.name
2029
const categoryName = field.category
@@ -245,12 +254,19 @@ $(document).ready(() => {
245254
clearInterval(tracking_interval)
246255
tracking_active = false
247256

248-
const link = document.createElement("a")
249-
link.href = BASE_URL + '/download/' + upload_ticket
257+
$downloadLink = $("<a />")
258+
$downloadLink.addClass("download-rom")
259+
$downloadLink.attr("href", BASE_URL + '/download/' + upload_ticket)
250260
const fileNameParts = fileNameSelected.split('.')
251261
const fileExt = fileNameParts[fileNameParts.length - 1]
252-
link.download = 'Super Mario 64 Randomizer ROM' + fileExt
253-
link.click()
262+
$downloadLink.attr("download", 'Super Mario 64 Randomizer ROM' + fileExt)
263+
$downloadLink.text("Download your ROM!")
264+
265+
if ($queueGenerationButton.next().hasClass("download-rom")) {
266+
$queueGenerationButton.next().remove()
267+
}
268+
$($queueGenerationButton).after($downloadLink)
269+
$downloadLink.get(0).click()
254270

255271
// queue-generation-message
256272
$queueGenerationButton.children("span").text("Queue for generation")
@@ -296,10 +312,11 @@ $(document).ready(() => {
296312
label: "ROM Receive failed: " + (errMessage != null ? errMessage : "(Unknown Error)")
297313
})
298314

315+
alert("Unfortunately the server returned an invalid response. Please try again later")
316+
299317
$queueGenerationButton.children("span").text("Queue for generation")
300318
$queueGenerationButton.prop("disabled", false)
301319
$queueGenerationButton.removeClass("indefinite")
302-
alert(error)
303320
return
304321
}
305322
})
@@ -356,6 +373,7 @@ $(document).ready(() => {
356373
e.preventDefault()
357374

358375
if (!$realUpload.val()) {
376+
alert("Please select a ROM that you want to randomize first!")
359377
return
360378
}
361379

@@ -367,6 +385,10 @@ $(document).ready(() => {
367385
formDataBlob.delete("fake-upload")
368386
formDataBlob.set("input_rom", dataBlob, "input_rom.zip")
369387

388+
if ($queueGenerationButton.next().hasClass("download-rom")) {
389+
$queueGenerationButton.next().remove()
390+
}
391+
370392
$queueGenerationButton.prop("disabled", true)
371393
$queueGenerationButton.children('span').text("Uploading...")
372394

web/generator.html

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<base href="sm64-randomizer" />
1111
<title>Super Mario 64 Randomizer</title>
1212

13+
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
1314
<link href="css/normalize.css" rel="stylesheet">
1415
<link href="css/main.css" rel="stylesheet">
1516
<link href="css/generator.css" rel="stylesheet">

web/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<meta name="description" content="Super Mario 64 Randomizer - Re-experience the classic game in new challenging ways">
99
<meta name="keywords" content="Super Mario 64, SM64, SM64 Randomizer, Modding, Hacking, SM64 Rando, Super Mario 64 Randomizer">
10-
10+
<base href="sm64-randomizer" />
1111
<title>Super Mario 64 Randomizer</title>
1212

13+
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
1314
<link href="css/normalize.css" rel="stylesheet">
1415
<link href="css/main.css" rel="stylesheet">
1516
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">

web/legal.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<meta name="description" content="Super Mario 64 Randomizer - Re-experience the classic game in new challenging ways">
99
<meta name="keywords" content="Super Mario 64, SM64, SM64 Randomizer, Modding, Hacking, SM64 Rando, Super Mario 64 Randomizer">
10-
10+
<base href="sm64-randomizer" />
1111
<title>Super Mario 64 Randomizer</title>
1212

13+
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
1314
<link href="css/normalize.css" rel="stylesheet">
1415
<link href="css/main.css" rel="stylesheet">
1516
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">

web/scss/generator.scss

+16-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ section .dropzone .dz-preview .dz-image {
4040
margin-left: 20px;
4141
}
4242
}
43-
43+
.field--type--text input {
44+
background: none;
45+
border: none;
46+
font-size: large;
47+
border-bottom: 2px solid white;
48+
color: white;
49+
text-align: right;
50+
}
4451
.field--type--text label, .field--type--select label, .field--type--file label {
4552
min-width: 200px;
4653
display: inline-block;
@@ -263,4 +270,12 @@ button.help:hover .tooltip-content {
263270
bottom: 0;
264271
transition: 1s ease width;
265272
box-shadow: 0 0 4px white;
273+
}
274+
275+
.download-rom {
276+
display: block;
277+
margin: 20px;
278+
color: white;
279+
font-size: larger;
280+
text-shadow: 0 0 2px white;
266281
}

0 commit comments

Comments
 (0)