EOSERV Forum > EOSERV > DialogBox newline help
Page: << 1 >>
DialogBox newline help
Author Message
Post #204353 DialogBox newline help

I was wondering if there was an appropriate way to make new lines with the FAMILY_QUEST, ACTION_DIALOG packet or a better solution. Obviously, I have tried the newline character and it just doesn't work.

I've been messing around for awhile online and the only solutions for the dialog I have seen have been to use WIN32 to measure the pixel width of the text/etc but I refuse to use this solution. What have you guys used to get around this?

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
5 years, 33 weeks ago
Post #204355 Re: DialogBox newline help

I have some code for this purpose that I threw together over a sleepless night a few years ago. I used it to format newlines in ping messages. I think Callum or someone else did something similar.

What I did though was pad the message with spaces whenever I encountered a newline or an area where a word would wrap. It relies on EOSERV util functions for measuring width rather than WinAPI calls.

I'll try and dig it up for you when I get home later.

Edit: It was Ryouken, not Callum. Here is his solution.

---
Want to learn to pixel?
Pixelsource.org
5 years, 33 weeks ago
Post #204356 Re: DialogBox newline help

-Edit: NVM, I did not notice that you refuse this solution, sorry.

whether a new line will be called or not depends on the pixel width of the text in the current line exceeding 195, which if it did, a new line will be called. The default font size and font name will decide the pixel width of a certain text.


-Default font size: 8
-Default font name: MS Sans Serif
-Pixel width of 'SPACE' in the default conditions: 3

  1. int Character::GetPixelWidth(std::string text)
  2. {
  3.  
  4.     SIZE sz;
  5.  
  6.     HDC hdc = GetDC(NULL);
  7.     int logicaly = GetDeviceCaps(hdc,LOGPIXELSY);
  8.     int lfHeight = MulDiv (8,logicaly, 72); 
  9.     HFONT font = CreateFont(lfHeight, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, "MS Sans Serif");
  10.     SelectObject(hdc, font);
  11.     GetTextExtentPoint32(hdc, text.c_str(), text.length(), &sz);
  12.     ReleaseDC(NULL, hdc);
  13.     return sz.cx;
  14.  
  15. }

 

  1.         int pixelwidth = GetPixelWidth(line);
  2.         int spacesn = ( 195 - pixelwidth ) / 3; //number of [SPACE] to make the line full.
5 years, 33 weeks ago
Post #204357 Re: DialogBox newline help
Cirras posted: (11th Sep 2018, 05:57 am)

I have some code for this purpose that I threw together over a sleepless night a few years ago. I used it to format newlines in ping messages. I think Callum or someone else did something similar.

What I did though was pad the message with spaces whenever I encountered a newline or an area where a word would wrap. It relies on EOSERV util functions for measuring width rather than WinAPI calls.

I'll try and dig it up for you when I get home later.

Edit: It was Ryouken, not Callum. Here is his solution.


Thanks this is something better that I was looking for but it still disappoints me that the dialog box doesn’t support new line characters. 


@freezingsoul this is the win32/gdi+ solution that I mentioned

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
5 years, 33 weeks ago
Page: << 1 >>

EOSERV Forum > EOSERV > DialogBox newline help