Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
7abd2f30
Verified
Commit
7abd2f30
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: support for background and extra settings
Theme stored in `localStorage`
parent
90b1bf28
No related branches found
No related tags found
No related merge requests found
Pipeline
#1817
passed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
frontends/web/index.ts
+1
-1
1 addition, 1 deletion
frontends/web/index.ts
frontends/web/ts/gb.ts
+19
-1
19 additions, 1 deletion
frontends/web/ts/gb.ts
with
21 additions
and
2 deletions
CHANGELOG.md
+
1
−
0
View file @
7abd2f30
...
...
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
*
Support for theme and palette selection
*
Theme stored in
`localStorage`
### Changed
...
...
This diff is collapsed.
Click to expand it.
frontends/web/index.ts
+
1
−
1
View file @
7abd2f30
...
...
@@ -40,7 +40,7 @@ const BACKGROUNDS = [
// creates the emulator structure and initializes the
// React app with both the parameters and the emulator
const
emulator
=
new
GameboyEmulator
();
const
emulator
=
new
GameboyEmulator
(
{
background
:
background
}
);
startApp
(
"
app
"
,
{
emulator
:
emulator
,
fullscreen
:
fullscreen
,
...
...
This diff is collapsed.
Click to expand it.
frontends/web/ts/gb.ts
+
19
−
1
View file @
7abd2f30
...
...
@@ -93,6 +93,18 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
private
romSize
=
0
;
private
cartridge
:
Cartridge
|
null
=
null
;
/**
* Associative map for extra settings to be used in
* opaque local storage operations, associated setting
* name with its value as a string.
*/
private
extraSettings
:
Record
<
string
,
string
>
=
{};
constructor
(
extraSettings
=
{})
{
super
();
this
.
extraSettings
=
extraSettings
;
}
/**
* Runs the initialization and main loop execution for
* the Game Boy emulator.
...
...
@@ -592,6 +604,11 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
}
}
onBackground
(
background
:
string
)
{
this
.
extraSettings
.
background
=
background
;
this
.
storeSettings
();
}
/**
* Tries to load game RAM from the `localStorage` using the
* current cartridge title as the name of the item and
...
...
@@ -620,7 +637,8 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
private
storeSettings
()
{
if
(
!
window
.
localStorage
)
return
;
const
settings
=
{
palette
:
PALETTES
[
this
.
paletteIndex
].
name
palette
:
PALETTES
[
this
.
paletteIndex
].
name
,
...
this
.
extraSettings
};
localStorage
.
setItem
(
"
settings
"
,
JSON
.
stringify
(
settings
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment