Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 1,258 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problem mit WWRAP / problem with WWRAP, please help ! #435330
01/06/14 12:14
01/06/14 12:14
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline OP
Member
Ascalon  Offline OP
Member

Joined: Apr 2005
Posts: 274
austria
Hallo, hab ein Problem mit WWRAP. Ich habe zwei Strings, einen mit langem Text und einen mit kurzem Text. Der lange Text wird durch WWRAP korrekt umgebrochen, aber der zweite Text wird dann vom ersten überlagert, also nicht in die richtige, nächste Zeile geschrieben. Wie bekommt der zweite String seine richtige Zeile,sodass er nicht vom ersten String überdeckt wird. Hier mein Codebeispiel

Hello, have a problem with WWRAP. I have two strings, a long one and a shorter one. The long text have a correct wordwrap with WWRAP, but the second text has an "overlay" from the first one. so the second one didn't get the right new line. How does the second string get his right number of line, so that the first string dont cover the second string. Here is my code example

Code:
#include <acknex.h>
#include <default.c>

STRING* strTest1 = "i am a very long text,i am a very long text, i am a very long text, i am a very long text";
STRING* strTest2 = "i am a short one";

TEXT* txtOut= {
	pos_x = 20; pos_y = 20;
	font = "Arial#20";
	strings = 10;
	string(strTest1,strTest2);
	size_x = 150;
	flags = SHOW | WWRAP;
}


function main() {
	
}



ps. sorry for my bad english


my webside : www.ascalon.jimdo.de
Re: Problem mit WWRAP / problem with WWRAP, please help ! [Re: Ascalon] #435332
01/06/14 12:22
01/06/14 12:22
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
This isn't possible with the engine functions. You have to write your own word wrap function. This can be easy done with str_width function (to detect end of a line).

Re: Problem mit WWRAP / problem with WWRAP, please help ! [Re: oliver2s] #435375
01/06/14 21:39
01/06/14 21:39
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline OP
Member
Ascalon  Offline OP
Member

Joined: Apr 2005
Posts: 274
austria
yeaaaaah! i think i managed to code my own WWRAP laugh but i don't know, if i coded it well tongue but it seems to work


my webside : www.ascalon.jimdo.de
Re: Problem mit WWRAP / problem with WWRAP, please help ! [Re: Ascalon] #435380
01/07/14 04:23
01/07/14 04:23
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Cool!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Problem mit WWRAP / problem with WWRAP, please help ! [Re: Superku] #435491
01/08/14 13:43
01/08/14 13:43
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline OP
Member
Ascalon  Offline OP
Member

Joined: Apr 2005
Posts: 274
austria
So, ich zeige euch mal meine Lösung für meinen Zeilenumbruch. Vielleicht habt ihr einen bessere Lösung bwz. Verbesserungen. Weiß nicht, wie gut ich meinen Code programmiert habe wink

So, i show you now my solution for my wraptext. Maybe you have a better solution or improvements. I don't know, how good i progged my code wink sorry, that i made no english comments

Code:
#include <acknex.h>
#include <default.c>

STRING* strTest1 = "Hinz und Kunz gingen durch die Stadt. Sie bemerkten nicht, dass es schon abend wurde und wie dunkel es draußen schon war.";
STRING* strTest2 = "i am a short one";
STRING* strTest3 = "so, die Geschichte geht nun weiter. Ich weiß auch nicht, was der Text vorhin sollte? Egal, wo sind wir stehen geblieben?";
STRING* s = "ABC";

FONT* arial_font = "Arial#20";

TEXT* txtOut= {
	pos_x = 20; pos_y = 20;
	font = arial_font;
	strings = 10;
	string(strTest1,strTest2,s,strTest3);
	size_x = 450;
	flags = SHOW;
}

//only for debugging
PANEL* panTest= {
	pos_x = 20; pos_y = 300;
	
	digits(0,0,"Länge: %.f","Arial#16",1,laenge);
	digits(0,20,"Zeichen: %.f","Arial#16",1,zeichen);
//	digits(0,40,"Rückgabe: %.f","Arial#16",1,rueckgabewert);	
	flags = SHOW;
}

var laenge;
var zeichen;
//var rueckgabewert;

function wrapString(STRING* _string) {	
	STRING* strTemp = " ";
	STRING* strOrginal = " ";
	var position; 	        //Speichert die Position des gefundenen Leerzeichens
	var abtrennung = 400;	//Nach wievielen Pixeln soll der Text umgebrochen werden
	
	str_cpy(strOrginal,_string);    //Speichert den Text um ihn im orginal zu erhalten

	zeichen = str_len(_string);	//Liefert die Anzahl der Zeichen im string
	
	var i;
	for(i = 1; i < zeichen; i++) {
		str_cpy(strTemp,strOrginal);                //Kopiert den Orginaltext in einen temporären String
		str_trunc(strTemp,zeichen-i);               //und kürzt diesen temp. String um die Anzahl der Zeichen - i.
		laenge = str_width(strTemp,arial_font);     //dieser gekürzte String wird dann auf seine Länge an Pixeln überprüft
		if(laenge >= abtrennung) {                  //wenn die Länge (in Pixel) des Strings zu lange ist
			position = str_chr(_string,-i,' '); //gehe von der aktuellen Position des Zeichens solange zurück, bis ein Leerzeichen gefunden wird
			str_setchr(_string,position,'\n');  //und ersetze das Leerzeichen mit einem Zeilenumbruch ('\n')
			abtrennung += 400;                  //dann erhöhe die Abtrennung um den gleichen Abstand für die nächste "Überlänge"
		}
	}
}

//only for testing
function changeText() {
	str_cpy(strTest2,"jetzt is er neu");
}

function main() {
	
	level_load(NULL);
	wait(3);
	
//	laenge = str_width(strTest1,arial_font);
//	zeichen = str_len(strTest1);

	wrapString(strTest1);
	wrapString(strTest3);
	
	on_p = changeText;
	//on_o = wrapString;
}



my webside : www.ascalon.jimdo.de
Re: Problem mit WWRAP / problem with WWRAP, please help ! [Re: Ascalon] #435777
01/14/14 04:23
01/14/14 04:23
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline
User
Dooley  Offline
User

Joined: May 2005
Posts: 868
Chicago, IL
Strange,
I was able to use WWRAP just fine.

I did not use SHOW, but called the text's SHOW flag through a function...


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1