|
3 registered members (AndrewAMD, juanex, Grant),
1,018
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
can make textbox and listbox ?
#243086
12/27/08 20:18
12/27/08 20:18
|
Joined: May 2008
Posts: 257
djfeeler
OP
Member
|
OP
Member
Joined: May 2008
Posts: 257
|
hello,
I wonder if with game studio can make textbox and listbox ? if yes how
Thank you in advance
Last edited by djfeeler; 12/27/08 20:19.
|
|
|
Re: can make textbox and listbox ?
[Re: djfeeler]
#243088
12/27/08 20:34
12/27/08 20:34
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
You are thinking of vb, read through the lite-c tutorials to learn how to print text on screen.
And a list box will require some more advanced knowledge of lite-c
(Unless you want C-Script, then i don't know, but you didn't say)
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: can make textbox and listbox ?
[Re: djfeeler]
#419102
03/06/13 11:15
03/06/13 11:15
|
tolu619
Unregistered
|
tolu619
Unregistered
|
So in other words, there's no way to make a textbox in Lite-C?
|
|
|
Re: can make textbox and listbox ?
[Re: ]
#419106
03/06/13 11:54
03/06/13 11:54
|
Joined: Sep 2007
Posts: 101 Luxembourg
krial057
Member
|
Member
Joined: Sep 2007
Posts: 101
Luxembourg
|
So in other words, there's no way to make a textbox in Lite-C? It is, but you have to program the textbox yourself. (or use the windows api) Here is an example of an implementation i did a time ago in Lite-C. You can select, copy, paste, etc. (depends on some other functions i wrote, but you can understand the main idea. If you want I can also post the rest of the code
int UITextGetCharacterIndexAtPos(int xOffset)
{
int i;
int sizeofa = str_width("a", UITextCurrentFont);
for(i = 0; i < str_len(UITextCurrent); i++)
{
STRING* temp = str_cut(NULL, UITextCurrent, 0, i+1);
str_cat(temp, "a");
int width = str_width(temp, UITextCurrentFont) - sizeofa;
if(width > xOffset)
{
return i+1;
}
}
return str_len(UITextCurrent) + 1;
}
int UITextGetCharacterPos(int index)
{
//a: fix sizeof space...(probably find a better solution :S)
if(index <= 1) return 0;
int sizeofa = str_width("a", UITextCurrentFont);
STRING* temp = _str("");
if(index > str_len(UITextCurrent))
str_cpy(temp, UITextCurrent);
else
temp = str_cut(NULL, UITextCurrent, 0, index - 1);
str_cat(temp, "a");
int width = str_width(temp, UITextCurrentFont) - sizeofa;
return width;
}
void UITextSelectionClear()
{
UITextSelectionStart = UITextCursorPos;
}
void UITextErease(int start, int end)
{
STRING* temp = _str("");
if(start > 1)
str_cut(temp, UITextCurrent, 0, start-1);
STRING* temp2 = _str("");
str_cut(temp2, UITextCurrent, end, 0);
str_cpy(UITextCurrent, temp);
str_cat(UITextCurrent, temp2);
}
void UITextInsert(int start, STRING* insertChar)
{
STRING* temp = _str("");
if(start > 1)
str_cut(temp, UITextCurrent, 0, start-1);
STRING* temp2 = _str("");
str_cut(temp2, UITextCurrent, start, 0);
str_cpy(UITextCurrent, temp);
str_cat(UITextCurrent, insertChar);
str_cat(UITextCurrent, temp2);
}
BOOL UITextSelectionErease()
{
if(UITextSelectionStart == UITextCursorPos) return false;
var start = minv(UITextSelectionStart, UITextCursorPos);
var end = maxv(UITextSelectionStart, UITextCursorPos);
UITextErease(start, end);
UITextSelectionStart = UITextCursorPos = start;
return true;
}
STRING* UITextSelectionGet()
{
var start = minv(UITextSelectionStart, UITextCursorPos);
var end = maxv(UITextSelectionStart, UITextCursorPos);
STRING* temp = _str("");
str_cut(temp, UITextCurrent, start, end);
return temp;
}
void UITextEditableRender(UIRect contentarea, int height, BOOL inRect)
{
if(inRect && IPGetKeyDown("Mouse left"))
{
UITextCursorPos = UITextGetCharacterIndexAtPos(IPMousePosition.x - contentarea->x);
if(!IPGetKey("shiftl") && !IPGetKey("shiftr"))
UITextSelectionClear();
}
if(inRect && IPGetKey("Mouse left"))
{
UITextCursorPos = UITextGetCharacterIndexAtPos(IPMousePosition.x - contentarea->x);
}
if(IPGetKeyDown("cul"))
{
UITextCursorPos = maxv(--UITextCursorPos, 1);
if(!IPGetKey("shiftl") && !IPGetKey("shiftr"))
UITextSelectionClear();
}
else if(IPGetKeyDown("cur"))
{
UITextCursorPos = minv(++UITextCursorPos, str_len(UITextCurrent)+1);
if(!IPGetKey("shiftl") && !IPGetKey("shiftr"))
UITextSelectionClear();
}
else if(IPGetKeyDown("home"))
{
if(!IPGetKey("shiftl") && !IPGetKey("shiftr"))
{
UITextCursorPos = 1;
UITextSelectionClear();
}
else
{
UITextSelectionStart = UITextCursorPos;
UITextCursorPos = 1;
}
}
else if(IPGetKeyDown("end"))
{
if(!IPGetKey("shiftl") && !IPGetKey("shiftr"))
{
UITextCursorPos = str_len(UITextCurrent)+1;
UITextSelectionClear();
}
else
{
UITextSelectionStart = UITextCursorPos;
UITextCursorPos = str_len(UITextCurrent)+1;
}
}
else if(IPGetKeyDown("bksp") || IPGetKeyDown("del"))
{
if(!UITextSelectionErease())
{
if(IPGetKeyDown("bksp") && str_len(UITextCurrent)>0 && UITextCursorPos>=1)
UITextErease(--UITextCursorPos, UITextCursorPos+1);
if(IPGetKeyDown("del") && str_len(UITextCurrent)>0 && UITextCursorPos <= str_len(UITextCurrent))
UITextErease(UITextCursorPos, UITextCursorPos+1);
UITextSelectionClear();
}
}
else if(IPGetKey("ctrl") && IPGetKeyDown("a"))
{
UITextCursorPos = 1;
UITextSelectionStart = str_len(UITextCurrent)+1;
}
else if(IPGetKey("ctrl") && (IPGetKeyDown("c") || IPGetKeyDown("x")))
{
if(OpenClipboard(hWnd))
{
EmptyClipboard();
long hClipboardData;
STRING* sel = UITextSelectionGet();
hClipboardData = GlobalAlloc(GMEM_DDESHARE, str_len(sel)+1);
char* pchData;
pchData = (char*)GlobalLock(hClipboardData);
strcpy(pchData, _chr(sel));
GlobalUnlock(hClipboardData);
SetClipboardData(CF_TEXT,hClipboardData);
CloseClipboard();
if(IPGetKeyDown("x"))
UITextSelectionErease();
}
}
else if(IPGetKey("ctrl") && IPGetKeyDown("v"))
{
if(OpenClipboard(hWnd))
{
UITextSelectionErease();
HANDLE hClipboardData = GetClipboardData(CF_TEXT);
char *pchData = (char*)GlobalLock(hClipboardData);
UITextInsert(UITextCursorPos, pchData);
UITextCursorPos += str_len(pchData);
UITextSelectionClear();
GlobalUnlock(hClipboardData);
CloseClipboard();
}
}
else if(IPLastCharAscii && str_getchr(IPLastChar, 1) != ' ' && IPLastCharAscii!=0 && IPLastCharAscii > 27 || IPLastCharAscii == 32)
{
//printf("%i", (int)IPLastCharAscii);
UITextSelectionErease();
UITextInsert(UITextCursorPos, IPLastChar);
UITextCursorPos++;
UITextSelectionClear();
}
int curPos = UITextGetCharacterPos(UITextCursorPos);
int startPos = UITextGetCharacterPos(UITextSelectionStart);
//Draw cursor
draw_quad(NULL, vector(contentarea->x + curPos, contentarea->y, 0), NULL, vector(1, height, 0), NULL, COLOR_WHITE, 100, 0);
//Draw selection
draw_quad(NULL, vector(contentarea->x + curPos, contentarea->y, 0), NULL, vector(startPos - curPos, height, 0), NULL, COLOR_WHITE, 40, 0);
}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|