Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Progark gruppe 3
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
Container registry
Model registry
Operate
Environments
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
Tobias Ingebrigt Ørstad
Progark gruppe 3
Commits
8a8d4c37
Commit
8a8d4c37
authored
5 years ago
by
ivarnm
Browse files
Options
Downloads
Patches
Plain Diff
#79
Change player_id to player object
parent
242a92d4
No related branches found
No related tags found
1 merge request
!76
Resolve "Local Storage"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/core/src/com/gameware/game/GameWare.java
+6
-13
6 additions, 13 deletions
frontend/core/src/com/gameware/game/GameWare.java
frontend/core/src/com/gameware/game/models/LocalStorage.java
+5
-6
5 additions, 6 deletions
frontend/core/src/com/gameware/game/models/LocalStorage.java
with
11 additions
and
19 deletions
frontend/core/src/com/gameware/game/GameWare.java
+
6
−
13
View file @
8a8d4c37
...
...
@@ -77,9 +77,10 @@ public class GameWare extends ApplicationAdapter {
musicOn
=
true
;
// Local Storage
gsm
.
push
(
new
LoginState
(
gsm
));
readFromLocalStorage
();
if
(
player
!=
null
)
{
if
(
player
==
null
)
{
gsm
.
push
(
new
LoginState
(
gsm
));
}
else
{
gsm
.
push
(
new
MenuState
(
gsm
));
}
if
(
musicOn
){
music
.
play
();}
...
...
@@ -194,11 +195,7 @@ public class GameWare extends ApplicationAdapter {
FileHandle
file
=
Gdx
.
files
.
local
(
localStorageFilePath
);
Json
json
=
new
Json
();
json
.
setUsePrototypes
(
false
);
String
playerId
=
null
;
if
(
player
!=
null
)
{
playerId
=
player
.
getId
();
}
LocalStorage
ls
=
new
LocalStorage
(
playerId
,
musicOn
,
soundEffects
,
includeFin
);
LocalStorage
ls
=
new
LocalStorage
(
player
,
musicOn
,
soundEffects
,
includeFin
);
String
lsString
=
json
.
toJson
(
ls
);
file
.
writeString
(
lsString
,
false
);
System
.
out
.
println
(
file
.
readString
());
...
...
@@ -210,11 +207,7 @@ public class GameWare extends ApplicationAdapter {
if
(!
file
.
exists
())
{
return
;
}
String
fileOutput
=
file
.
readString
();
LocalStorage
ls
=
new
Json
().
fromJson
(
LocalStorage
.
class
,
fileOutput
);
if
(
ls
.
get_id
()
!=
null
)
{
try
{
player
=
QueryIntermediate
.
getPlayerById
(
ls
.
get_id
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();}
}
if
(
ls
.
getPlayer
()
!=
null
)
{
player
=
ls
.
getPlayer
();
}
if
(
ls
.
getMusicOn
()
!=
null
)
{
musicOn
=
ls
.
getMusicOn
();
}
if
(
ls
.
getSoundEffects
()!=
null
){
soundEffects
=
ls
.
getSoundEffects
();
}
if
(
ls
.
getIncludeFin
()
!=
null
)
{
includeFin
=
ls
.
getIncludeFin
();
}
...
...
This diff is collapsed.
Click to expand it.
frontend/core/src/com/gameware/game/models/LocalStorage.java
+
5
−
6
View file @
8a8d4c37
package
com.gameware.game.models
;
public
class
LocalStorage
{
// private Player player;
private
String
_id
;
//playerId
private
Player
player
;
private
Boolean
musicOn
;
private
Boolean
soundEffects
;
private
Boolean
includeFin
;
...
...
@@ -10,15 +9,15 @@ public class LocalStorage {
public
LocalStorage
()
{
}
public
LocalStorage
(
String
_id
,
Boolean
musicOn
,
Boolean
soundEffects
,
Boolean
includeFin
)
{
this
.
_id
=
_id
;
public
LocalStorage
(
Player
player
,
Boolean
musicOn
,
Boolean
soundEffects
,
Boolean
includeFin
)
{
this
.
player
=
player
;
this
.
musicOn
=
musicOn
;
this
.
soundEffects
=
soundEffects
;
this
.
includeFin
=
includeFin
;
}
public
String
get_id
()
{
return
_id
;
public
Player
getPlayer
()
{
return
player
;
}
public
Boolean
getMusicOn
()
{
...
...
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