Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RLG Maker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Romain DELEAU
RLG Maker
Commits
7c466741
Commit
7c466741
authored
Jun 16, 2023
by
Romain DELEAU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix load json
parent
0189c315
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
11 deletions
+76
-11
app.component.html
src/app/app.component.html
+1
-1
app.component.ts
src/app/app.component.ts
+75
-10
No files found.
src/app/app.component.html
View file @
7c466741
...
@@ -118,7 +118,7 @@
...
@@ -118,7 +118,7 @@
<label
for=
"unity"
>
Intégrer le jeu sous Unity
</label>
<label
for=
"unity"
>
Intégrer le jeu sous Unity
</label>
</div>
</div>
<button
mat-mini-fab
color=
"white"
(
click
)="
downloadFile
()"
><mat-icon
fontIcon=
"download_file"
></mat-icon></button>
<button
mat-mini-fab
color=
"white"
(
click
)="
downloadFile
()"
><mat-icon
fontIcon=
"download_file"
></mat-icon></button>
<button
mat-mini-fab
color=
"white"
(
click
)="
test
()"
><mat-icon
fontIcon=
"upload-file"
></mat-icon></button>
<button
mat-mini-fab
color=
"white"
><mat-icon
fontIcon=
"upload-file"
></mat-icon></button>
<input
type=
"file"
(
change
)="
onFileSelected
($
event
)"
>
<input
type=
"file"
(
change
)="
onFileSelected
($
event
)"
>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/app/app.component.ts
View file @
7c466741
import
{
Component
}
from
'@angular/core'
;
import
{
C
hangeDetectorRef
,
C
omponent
}
from
'@angular/core'
;
import
{
Mission
}
from
'./class/mission/mission'
;
import
{
Mission
}
from
'./class/mission/mission'
;
import
{
Scenario
}
from
'./class/scenario/scenario'
;
import
{
Scenario
}
from
'./class/scenario/scenario'
;
import
{
Step
}
from
'./class/step/step'
;
import
{
Step
}
from
'./class/step/step'
;
import
{
Task
}
from
'./class/task/task'
;
import
{
Task
}
from
'./class/task/task'
;
import
{
Role
}
from
'./class/role/role'
;
import
{
Role
}
from
'./class/role/role'
;
import
{
GameContext
}
from
'./class/game-context/game-context'
;
import
{
GameEducationnalObjective
}
from
'./class/game-educationnal-objective/game-educationnal-objective'
;
import
{
Character
}
from
'./class/character/character'
;
import
{
Ressource
}
from
'./class/ressource/ressource'
;
import
{
MissionContext
}
from
'./class/mission-context/mission-context'
;
import
{
EducationnalObjective
}
from
'./class/educationnal-objective/educationnal-objective'
;
import
{
RoleOccurrence
}
from
'./class/role-occurrence/role-occurrence'
;
import
{
SupplementaryRole
}
from
'./class/supplementary-role/supplementary-role'
;
import
{
Symbol
}
from
'./class/symbol/symbol'
;
@
Component
({
@
Component
({
selector
:
'app-root'
,
selector
:
'app-root'
,
...
@@ -13,20 +22,14 @@ import { Role } from './class/role/role';
...
@@ -13,20 +22,14 @@ import { Role } from './class/role/role';
export
class
AppComponent
{
export
class
AppComponent
{
title
=
'RLG Maker'
;
title
=
'RLG Maker'
;
scenario
:
Scenario
;
scenario
:
Scenario
=
new
Scenario
();
constructor
()
{
this
.
scenario
=
new
Scenario
();
constructor
(
private
cdr
:
ChangeDetectorRef
)
{
this
.
scenario
.
missions
.
forEach
(
mission
=>
{
this
.
scenario
.
missions
.
forEach
(
mission
=>
{
mission
.
equalizeLengths
();
mission
.
equalizeLengths
();
});
});
}
}
test
():
void
{
}
downloadFile
():
void
{
downloadFile
():
void
{
const
jsonString
=
JSON
.
stringify
(
this
.
scenario
);
const
jsonString
=
JSON
.
stringify
(
this
.
scenario
);
const
blob
=
new
Blob
([
jsonString
],
{
type
:
'application/json'
});
const
blob
=
new
Blob
([
jsonString
],
{
type
:
'application/json'
});
...
@@ -45,8 +48,70 @@ export class AppComponent {
...
@@ -45,8 +48,70 @@ export class AppComponent {
reader
.
readAsText
(
file
);
reader
.
readAsText
(
file
);
reader
.
onload
=
(
e
)
=>
{
reader
.
onload
=
(
e
)
=>
{
const
fileContent
:
string
=
reader
.
result
as
string
;
const
fileContent
:
string
=
reader
.
result
as
string
;
const
scenario
:
Scenario
=
JSON
.
parse
(
fileContent
)
as
Scenario
;
const
jsonData
:
any
=
JSON
.
parse
(
fileContent
);
const
scenario
:
Scenario
=
Object
.
assign
(
new
Scenario
(),
jsonData
);
scenario
.
context
=
Object
.
assign
(
new
GameContext
(),
jsonData
.
context
);
scenario
.
context
.
comments
=
jsonData
.
context
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
(),
commentData
));
scenario
.
educationnalObjective
=
Object
.
assign
(
new
GameEducationnalObjective
(),
jsonData
.
educationnalObjective
);
scenario
.
educationnalObjective
.
comments
=
jsonData
.
educationnalObjective
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
(),
commentData
));
scenario
.
gameRules
=
jsonData
.
gameRules
;
scenario
.
characters
=
jsonData
.
characters
.
map
((
characterData
:
any
)
=>
Object
.
assign
(
new
Character
(),
characterData
));
scenario
.
ressources
=
jsonData
.
ressources
.
map
((
ressourceData
:
any
)
=>
Object
.
assign
(
new
Ressource
(),
ressourceData
));
scenario
.
missions
=
jsonData
.
missions
.
map
((
missionData
:
any
)
=>
Object
.
assign
(
new
Mission
(),
missionData
));
scenario
.
missions
.
forEach
((
mission
,
index
)
=>
{
mission
.
chronologie
=
jsonData
.
missions
[
index
].
chronologie
.
map
((
chronologieData
:
any
)
=>
{
if
(
chronologieData
!==
null
)
{
return
Object
.
assign
(
new
Step
(),
chronologieData
);
}
else
{
return
null
;
}
});
mission
.
chronologie
.
forEach
((
step
)
=>
{
if
(
step
instanceof
Step
)
{
step
.
comments
=
step
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
(),
commentData
));
}
});
mission
.
context
=
Object
.
assign
(
new
MissionContext
(),
jsonData
.
missions
[
index
].
context
);
mission
.
context
.
comments
=
jsonData
.
missions
[
index
].
context
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
(),
commentData
));
mission
.
educationnalObjective
=
Object
.
assign
(
new
EducationnalObjective
(),
jsonData
.
missions
[
index
].
educationnalObjective
);
mission
.
educationnalObjective
.
comments
=
jsonData
.
missions
[
index
].
educationnalObjective
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
,
commentData
));
mission
.
roles
=
jsonData
.
missions
[
index
].
roles
.
map
((
roleData
:
any
)
=>
Object
.
assign
(
new
Role
(),
roleData
));
mission
.
roles
.
forEach
((
role
,
index
)
=>
{
role
.
comments
=
role
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
(),
commentData
));
role
.
chronologie
=
mission
.
roles
[
index
].
chronologie
.
map
((
chronologieData
:
any
)
=>
{
if
(
chronologieData
!==
null
)
{
return
Object
.
assign
(
new
Step
(),
chronologieData
);
}
else
{
return
null
;
}
});
role
.
chronologie
.
forEach
((
step
)
=>
{
if
(
step
instanceof
Step
)
{
step
.
comments
=
step
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
(),
commentData
));
}
});
role
.
ressources
=
role
.
ressources
.
map
((
ressourceData
:
any
)
=>
Object
.
assign
(
new
Ressource
(),
ressourceData
));
role
.
occurences
=
role
.
occurences
.
map
((
occurrenceData
:
any
)
=>
Object
.
assign
(
new
RoleOccurrence
(),
occurrenceData
));
role
.
supplementaryRoles
=
role
.
supplementaryRoles
.
map
((
supplementaryRoleData
:
any
)
=>
Object
.
assign
(
new
SupplementaryRole
(),
supplementaryRoleData
));
role
.
tasks
.
forEach
((
inlineTasks
:
any
[],
index
:
number
)
=>
{
role
.
tasks
[
index
]
=
inlineTasks
.
map
((
taskData
:
any
)
=>
{
if
(
taskData
!==
null
)
{
return
Object
.
assign
(
new
Task
(
taskData
.
type
),
taskData
);
}
else
{
return
null
;
}
});
role
.
tasks
[
index
].
forEach
(
task
=>
{
if
(
task
instanceof
Task
)
{
task
.
comments
=
task
.
comments
.
map
((
commentData
:
any
)
=>
Object
.
assign
(
new
Comment
(),
commentData
));
task
.
symbol
=
Object
.
assign
(
new
Symbol
(),
task
.
symbol
);
}
});
});
});
});
this
.
scenario
=
scenario
;
this
.
scenario
=
scenario
;
this
.
cdr
.
detectChanges
();
};
};
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment