• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
anders211

How to convert WCHAR* table into the table which fits some editBox?

2 posts in this topic

How to convert the text into the text which is align to the some width (so also how to divide the text into multiline and align between left and right border (not center))? What is more we use only ID3DXFont::DrawTextW, ScriptStringAnalyse and similar Script functions. We assume that we don't use any SetTextAlign. Is any simple way, better than below one?
My approach in pseudocode:
- invoke analyse sth like that:
[CODE]
HDC hDC = mFont->font->GetDC();
HRESULT hr = ScriptStringAnalyse(hDC,
mBuffer,
lstrlenW(mBuffer) + 1, // NULL is also analyzed
lstrlenW(mBuffer) * 3/2 + 16, //size of buffer for glyph, recommended value 1.5 * length + 16
-1, //for unicode set -1
SSA_BREAK | SSA_GLYPHS | SSA_FALLBACK | SSA_LINK, // | SSA_FIT, SSA_CLIP
0, //127 this is piece of shit in the msdn, it doesn't divide the text into width = 127 px I have to do it on my own:/
&ScriptControl,
&ScriptState,
NULL,
NULL,
NULL,
&mAnalysis);[/CODE]

- then go trough each buffer character and collect the full words which are able to fit into the Width of editBox and catch all the specific ' ' which then You have to change into '\n' character.

This approach was improved, after each modification ' ' into '\n' I have to invoke again analyse(), because the X coordinates of chars change when You replace ' ' into '\n'.
However this approach doesn't solve the problem of alignment the text. Here I don't have idea. So in other words I would like to have the divided text and alignment to both borders in the buffer! That is why any setTextAlign function cannot be used.

This is my code which is trying to modify the mBuffer.
[CODE]
void Buffer::transformText(i32 width)
{
if(width < 0)
return;

if(mAnalyseRequired)
if(analyse() != OK)
return;

const SCRIPT_LOGATTR* pLogAttr = ScriptString_pLogAttr(mAnalysis);
if(!pLogAttr)
return;

if(!ScriptString_pcOutChars(mAnalysis))
return;

i32 limit = *ScriptString_pcOutChars(mAnalysis);

//calculate number of words
u32 numWords = 1;
for(i32 i=0; i<limit - 1; ++i) //without '\0'
if(pLogAttr[i].fWordStop && mBuffer[i] != '\n') //'\n' is also softBreak, charStop and wordStop
++numWords;

//vector<i32> znaczniki;
mBeginMarks.clear();
mBeginMarks.swap(vector<i32>(mBeginMarks));
mBeginMarks.push_back(0);
mLines = 1;
i32 fromBegX = 0;
i32 charNr = 0;
for(i32 i=0; i<limit; ++i)
{
(void)mBuffer[i];
if((pLogAttr[i].fWhiteSpace && !pLogAttr[i+1].fWhiteSpace) || mBuffer[i] == '\n' || mBuffer[i] == '\0')
{
i32 X;
CPtoX(i, FALSE, &X);
if(width >= X-fromBegX && mBuffer[i] != '\n')
charNr = i; //remember the last succeed char number
else
{
if(mBuffer[i] == '\n')
charNr = i;
else
mBuffer[charNr] = '\n';
mAnalyseRequired = true;
analyse();
pLogAttr = ScriptString_pLogAttr(mAnalysis);
if(!pLogAttr)
return;
if(!ScriptString_pcOutChars(mAnalysis))
return;
limit = *ScriptString_pcOutChars(mAnalysis);
CPtoX(charNr, TRUE, &X);
fromBegX = X; //+= width;
++mLines;
//znaczniki.push_back(charNr);
mBeginMarks.push_back(X); //remember the X coordinate of the lines first chars
}
}
}

/*i32 size = static_cast<i32>(znaczniki.size());
for(i32 i = 0; i<size; ++i)
mBuffer[znaczniki[i]] = '\n';*/
}[/CODE] Edited by anders211
0

Share this post


Link to post
Share on other sites
What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?
0

Share this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1355931934' post='5012471']
What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?
[/quote]
OK I updated the first post. I have just written also to microsoft because this task is a bit challange and maybe not solvable.


I am in the middle of implementation my own multiline EditBox control (based on oneline EditBox from CDXUT Utility). I divided my text (which is kept in WCHAR * buffer) into lines (replacing some ' ' into '\n' between breakable words) and now my text fits into the width of EditBox but I have a problem how can I now justify (align) the text. I have to have aligment text in the buffer because only in this way when I click with the aid of mouse on the editBox, the caret will be set at the given char perfectly. I suppose it can be done with some scriptStringMethods but I don't have idea how to use them to cause the effect which I would like.
Thanks in advance for help Edited by anders211
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0