diff --git a/assets/converters.py b/assets/converters.py index d63ee8f..a44f06b 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -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" ] ) ) diff --git a/assets/fxconv-metadata.txt b/assets/fxconv-metadata.txt index 9150b69..17810e2 100644 --- a/assets/fxconv-metadata.txt +++ b/assets/fxconv-metadata.txt @@ -2,6 +2,6 @@ WorldRPG.world: custom-type: world name: worldRPG -DialogsRPG.json +DialogsRPG.json: custom-type: dialogs name: dialogRPG diff --git a/assets/level0.tmx b/assets/level0.tmx index a3b4853..4554f3b 100644 --- a/assets/level0.tmx +++ b/assets/level0.tmx @@ -146,7 +146,7 @@ - + diff --git a/src/game.h b/src/game.h index ac70e88..c7e7164 100644 --- a/src/game.h +++ b/src/game.h @@ -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 ? */ diff --git a/src/main.c b/src/main.c index 4815df8..656ba64 100644 --- a/src/main.c +++ b/src/main.c @@ -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; inbextradata; 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 diff --git a/src/player.c b/src/player.c index 8e30a89..542596f 100644 --- a/src/player.c +++ b/src/player.c @@ -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;