Ok, bugs are fixed - need now to implement dialog sequence and automatic story mode

This commit is contained in:
SlyVTT 2023-08-21 22:53:33 +02:00
parent 35e173f838
commit 4a81853505
6 changed files with 35 additions and 20 deletions

View file

@ -6,6 +6,7 @@ import pathlib
import csv
import os
def convert(input, output, params, target):
if params["custom-type"] == "map":
print("ERROR : Asset ", params["name"], " has legacy type map")
@ -275,16 +276,14 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
if v[ "id" ] == pathID:
print( "path data found : " )
xdata = bytes("", "UTF-16")
ydata = bytes("", "UTF-16")
xdata = bytes()
ydata = bytes()
for w in v[ "polyline" ]:
path_length = path_length + 1
print( "X= ", w[ "x" ], " Y= ", w[ "y" ] )
xdata += fxconv.u16( int( w[ "x" ] ) )
ydata += fxconv.u16( int( w[ "y" ] ) )
print("xdata : ", xdata)
print("ydata : ", ydata)
else:
print( "PNJ has no Path" )
@ -292,17 +291,17 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
else:
print( "UNIDENTIFIED PROPERTY : ", j["name"])
print( "OBJECT X= ", x, " Y= ", y, "STR= ", dialog )
print( "OBJECT X= ", x, " Y= ", y, "STR= ", dialogID )
print( " Type= ", tpe, " Name= ", nme )
print( " Q?= ", quest, " Choi= ", choi )
print( " c1= ", conc1, " c2=", conc2)
print( " Action?= ", needAction )
structData += fxconv.u32( int(x) )
structData += fxconv.u32( int(y) )
structData += fxconv.string( nme )
structData += fxconv.string( tpe )
structData += fxconv.u32( int(dialogID))
structData += fxconv.u32( int(dialogID) )
structData += fxconv.u32( int(needAction) )
if path==0:
@ -323,7 +322,8 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
#else we do nothing (yet)
else:
break
print( "Skip this object" )
return nbExtraData, structData
@ -355,13 +355,23 @@ def convert_dialogs(input, output, params, target):
structDialogs = fxconv.Structure()
for d in data["dialogs"]:
print( int(d[ "ID" ]))
# print( d[ "dialog" ] )
print( int(d[ "isQuestion" ]) )
# print( d[ "choice" ].replace('$', chr(0)) )
# print( d[ "conclusion1" ] )
# print( int(d[ "next1" ] ) )
# print( d[ "conclusion2" ] )
# print( int(d[ "next2" ] ) )
# print( int(d[ "nextOther" ]) )
structDialogs += fxconv.u32( int(d[ "ID" ] ) )
structDialogs += fxconv.string( int(d[ "dialog" ] ) )
structDialogs += fxconv.string( d[ "dialog" ] )
structDialogs += fxconv.u32( int(d[ "isQuestion" ] ) )
structDialogs += fxconv.string( int(d[ "choice" ] ) )
structDialogs += fxconv.string( int(d[ "conclusion1" ] ) )
structDialogs += fxconv.string( d[ "choice" ].replace('$', chr(0)) )
structDialogs += fxconv.string( d[ "conclusion1" ] )
structDialogs += fxconv.u32( int(d[ "next1" ] ) )
structDialogs += fxconv.string( int(d[ "conclusion2" ] ) )
structDialogs += fxconv.string( d[ "conclusion2" ] )
structDialogs += fxconv.u32( int(d[ "next2" ] ) )
structDialogs += fxconv.u32( int(d[ "nextOther" ] ) )

View file

@ -2,6 +2,6 @@ WorldRPG.world:
custom-type: world
name: worldRPG
DialogsRPG.json
DialogsRPG.json:
custom-type: dialogs
name: dialogRPG

View file

@ -146,7 +146,7 @@
<object id="9" name="Chemin Crémier" type="TRJ" x="251.967" y="164.12">
<polyline points="0,0 -72.25,-18.5 -171.75,-19 -172.5,-99.25 -206.25,-122.75 -140.75,-114.75 -175.25,-97.5 -174.5,-33 -148.25,-20.5 -73.25,-20.25 39,-30.25 81.25,-45 79.25,-24.5"/>
</object>
<object id="11" name="DébutHistoire" type="INFO" x="71.3333" y="84.6667">
<object id="11" name="DébutHistoire" type="INFO" x="18.6666" y="42.6667">
<properties>
<property name="dialogID" type="int" value="0"/>
<property name="needAction" type="int" value="0"/>

View file

@ -43,6 +43,7 @@ typedef struct {
typedef struct {
uint32_t ID;
/* data to be shown in the dialog*/
char *dialog;
/* is it a question or a simple dialog ? */

View file

@ -28,6 +28,7 @@ extern bopti_image_t player_face_img;
extern Map *worldRPG[];
extern Dialog dialogRPG[];
/* Game data (defined in "game.h")*/
Game game = {
@ -153,10 +154,12 @@ int main(void) {
{
dfont( NULL );
for (int i=0; i<game.map_level->nbextradata; i++ )
dprint( 10, 90+i*15, C_RED, "X= %d - Y= %d - T: %s",
dprint( 10, 90+i*15, C_RED, "X= %d - Y= %d - T: %d - ID: %d - S: %c",
game.map_level->extradata[i].x,
game.map_level->extradata[i].y,
game.map_level->extradata[i].dialogID );
game.map_level->extradata[i].dialogID,
dialogRPG[ game.map_level->extradata[i].dialogID ].ID,
dialogRPG[ game.map_level->extradata[i].dialogID ].conclusion1[0] );
}
#endif

View file

@ -32,7 +32,7 @@ extern bopti_image_t SGN_Icon_img;
extern bopti_image_t INFO_Icon_img;
extern Dialog *dialogRPG;
extern Dialog dialogRPG[];
void player_draw(Game *game) {
@ -97,9 +97,10 @@ void player_action(Game *game) {
ExtraData *currentData = &game->map_level->extradata[game->player.whichAction];
/* we collect the information */
char *text = currentData->dialogID;
char *text = dialogRPG[ currentData->dialogID].dialog;
/* we use the correct image as per the class of the item */
bopti_image_t *face;
if (strcmp("INFO", currentData->type)==0)
face = &INFO_Icon_img;
else if (strcmp("NPC", currentData->type)==0)
@ -109,7 +110,7 @@ void player_action(Game *game) {
else face = &demo_player_img;
/* we treat the action - i.e. we show a dialog */
if (dialogRPG[ currentData->dialogID ].isQuestion ==1) /* we have to manage a question */
if (dialogRPG[ currentData->dialogID ].isQuestion == 1) /* we have to manage a question */
{
char *choices = dialogRPG[ currentData->dialogID].choices ;
char *conclusion1 = dialogRPG[currentData->dialogID].conclusion1;