mirror of https://github.com/bgiraudr/Adoranda.git
Retour à la ligne (experimental)
This commit is contained in:
parent
6cb8167eba
commit
1b5cd7a80f
|
@ -36,7 +36,7 @@
|
|||
<object id="36" gid="267" x="80" y="64" width="16" height="16">
|
||||
<properties>
|
||||
<property name="name" value="Inconnu"/>
|
||||
<property name="text" value="Bienvenue dans un monde différent"/>
|
||||
<property name="text" value="123456789123456789123456789123456789123456789"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="100" height="38" tilewidth="16" tileheight="16" infinite="0" nextlayerid="12" nextobjectid="52">
|
||||
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="100" height="38" tilewidth="16" tileheight="16" infinite="0" nextlayerid="12" nextobjectid="54">
|
||||
<editorsettings>
|
||||
<export target="testCarte.json" format="json"/>
|
||||
</editorsettings>
|
||||
|
@ -58,7 +58,7 @@
|
|||
0,743,744,745,746,274,53,54,0,275,0,53,54,274,0,0,0,0,0,0,0,0,0,0,0,0,108,0,0,0,0,0,0,0,0,111,0,0,0,0,0,0,0,113,0,656,657,658,659,108,0,0,0,378,379,380,0,0,0,0,0,0,0,0,0,0,82,138,139,0,0,0,0,0,0,0,0,0,0,0,0,303,0,722,723,724,725,0,0,0,0,0,635,636,637,638,0,245,0,0,
|
||||
0,0,29,0,0,303,0,0,0,304,0,0,0,303,0,0,0,0,0,0,0,0,0,0,0,0,108,0,0,0,0,0,0,0,0,111,0,0,0,0,0,0,0,113,0,685,686,687,688,137,84,174,0,0,0,0,0,0,0,0,0,0,0,0,0,82,139,111,0,0,18,19,0,0,0,0,0,0,0,0,0,0,0,751,752,753,754,0,0,0,0,0,664,665,666,667,0,274,0,0,
|
||||
0,0,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,635,636,637,638,0,79,142,0,0,0,0,0,0,0,0,111,0,0,0,0,0,29,0,113,0,714,715,716,717,0,137,203,138,138,84,0,0,0,0,0,0,0,82,138,138,139,0,140,81,0,47,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,25,0,0,693,694,695,696,0,303,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,664,665,666,667,0,108,0,0,0,0,0,0,0,0,0,111,0,0,0,0,0,58,0,113,0,743,744,745,746,0,0,232,0,0,137,138,138,138,138,138,138,138,139,0,0,0,0,0,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,53,54,0,0,722,723,724,725,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,664,665,666,667,0,108,0,0,0,0,0,0,0,0,0,111,0,239,0,0,0,58,0,113,0,743,744,745,746,0,0,232,0,0,137,138,138,138,138,138,138,138,139,0,0,0,0,0,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,53,54,0,0,722,723,724,725,0,0,0,0,
|
||||
0,0,0,0,0,0,245,0,0,245,0,0,0,0,0,0,0,0,0,0,693,694,695,696,0,108,0,0,0,0,0,0,0,0,0,111,0,0,0,0,0,0,0,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,111,0,0,0,0,0,0,0,0,0,635,636,637,638,0,0,0,245,0,0,0,0,245,0,751,752,753,754,0,0,0,0,
|
||||
0,0,320,321,322,0,274,0,0,274,0,0,0,0,0,0,0,0,0,0,722,723,724,725,0,108,0,0,0,0,0,0,0,0,0,140,141,141,141,141,141,141,141,142,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,320,321,322,0,0,0,111,0,0,323,324,325,0,0,0,0,664,665,666,667,0,0,0,274,0,323,324,325,274,0,0,0,0,0,0,0,0,0,
|
||||
0,0,349,350,351,0,303,0,0,303,0,0,0,0,0,0,0,0,0,0,751,752,753,754,0,137,84,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,349,350,351,0,0,0,111,0,0,352,353,354,0,0,0,0,693,694,695,696,0,0,0,303,0,352,353,354,303,0,0,0,0,0,0,0,0,0,
|
||||
|
@ -183,8 +183,8 @@
|
|||
<objectgroup id="11" name="teleporter">
|
||||
<object id="50" gid="238" x="448" y="528" width="16" height="16">
|
||||
<properties>
|
||||
<property name="x" type="int" value="29"/>
|
||||
<property name="y" type="int" value="29"/>
|
||||
<property name="x" type="int" value="42"/>
|
||||
<property name="y" type="int" value="9"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="51" gid="238" x="480" y="544" width="16" height="16">
|
||||
|
@ -194,5 +194,11 @@
|
|||
<property name="y" type="int" value="5"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="53" gid="238" x="592" y="176" width="16" height="16">
|
||||
<properties>
|
||||
<property name="x" type="int" value="30"/>
|
||||
<property name="y" type="int" value="30"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
</map>
|
||||
|
|
|
@ -13,4 +13,5 @@ struct Talkable {
|
|||
/*draw the dialog of a specified talkable tile*/
|
||||
void draw_dialog(struct Talkable *character);
|
||||
/*find the talkable tile using the player's position*/
|
||||
struct Talkable* get_dialog_xy(struct Map *map, int x, int y);
|
||||
struct Talkable* get_dialog_xy(struct Map *map, int x, int y);
|
||||
void clean(char *var);
|
|
@ -5,6 +5,8 @@
|
|||
#include "talkable.h"
|
||||
#include "util.h"
|
||||
|
||||
#define LIMIT 35
|
||||
|
||||
struct Talkable default_value = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
|
@ -22,13 +24,48 @@ void draw_dialog(struct Talkable *talkable) {
|
|||
while(curr_line != NULL) {
|
||||
drect(20,10,370,80,C_WHITE);
|
||||
dprint(25,20, C_BLACK, "%s", talkable->name);
|
||||
dprint(25,40, C_BLACK, "%s", curr_line);
|
||||
|
||||
//TODO Il y a moyen de faire mieux avec seulement curr_line.
|
||||
//Cela semble globalement fonctionner, mais j'ai pu oobserver des petites erreurs
|
||||
if(strlen(curr_line) > LIMIT) {
|
||||
char remain[strlen(curr_line)+1];
|
||||
char split[LIMIT+1];
|
||||
char first_part[LIMIT+1];
|
||||
|
||||
strcpy(remain, curr_line);
|
||||
int indexLine = 0;
|
||||
|
||||
while(strlen(remain) > LIMIT) {
|
||||
clean(split);
|
||||
strncpy(first_part,&remain[0],LIMIT);
|
||||
|
||||
char* find = strrchr(first_part,' ');
|
||||
int indexSpace = find != NULL ? (int)(find-first_part) : LIMIT-1;
|
||||
strncpy(split,&remain[0],indexSpace);
|
||||
strncpy(remain,&remain[indexSpace]+1,strlen(remain));
|
||||
|
||||
dprint(25,40+indexLine*15, C_BLACK, "%s", split);
|
||||
indexLine++;
|
||||
}
|
||||
dprint(25,40+indexLine*15, C_BLACK, "%s", remain);
|
||||
} else {
|
||||
dprint(25,40, C_BLACK, "%s", curr_line);
|
||||
}
|
||||
|
||||
dupdate();
|
||||
curr_line = strtok(NULL, delim);
|
||||
wait_for_input(KEY_SHIFT);
|
||||
}
|
||||
}
|
||||
|
||||
void clean(char *var) {
|
||||
int i = 0;
|
||||
while(var[i] != '\0') {
|
||||
var[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/*find the talkable tile using the player's position*/
|
||||
struct Talkable* get_dialog_xy(struct Map *map, int x, int y) {
|
||||
int i = 0;
|
||||
|
|
Loading…
Reference in New Issue