-#ifdef INTERFACE
-CLASS(InputBox) EXTENDS(Label)
+#ifndef ITEM_INPUTBOX_H
+#define ITEM_INPUTBOX_H
+#include "label.qc"
+CLASS(InputBox, Label)
METHOD(InputBox, configureInputBox, void(entity, string, float, float, string))
METHOD(InputBox, draw, void(entity))
METHOD(InputBox, setText, void(entity, string))
ATTRIB(InputBox, scrollPos, float, 0) // widths
ATTRIB(InputBox, focusable, float, 1)
+ ATTRIB(InputBox, allowFocusSound, float, 1)
ATTRIB(InputBox, disabled, float, 0)
ATTRIB(InputBox, lastChangeTime, float, 0)
ATTRIB(InputBox, dragScrollTimer, float, 0)
ATTRIB(InputBox, cb_colorF, vector, '1 1 1')
ATTRIB(InputBox, cb_colorC, vector, '1 1 1')
ENDCLASS(InputBox)
-void InputBox_Clear_Click(entity btn, entity me);
#endif
#ifdef IMPLEMENTATION
SUPER(InputBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
if (me.enableClearButton)
{
- me.cb_width = absSize_y / absSize_x;
+ me.cb_width = absSize.y / absSize.x;
me.cb_offset = bound(-1, me.cb_offset, 0) * me.cb_width; // bound to range -1, 0
me.keepspaceRight = me.keepspaceRight - me.cb_offset + me.cb_width;
}
SUPER(InputBox).setText(me, strzone(txt));
}
-void InputBox_Clear_Click(entity btn, entity me)
-{
- me.setText(me, "");
-}
-
float over_ClearButton(entity me, vector pos)
{
- if (pos_x >= 1 + me.cb_offset - me.cb_width)
- if (pos_x < 1 + me.cb_offset)
- if (pos_y >= 0)
- if (pos_y < 1)
+ if (pos.x >= 1 + me.cb_offset - me.cb_width)
+ if (pos.x < 1 + me.cb_offset)
+ if (pos.y >= 0)
+ if (pos.y < 1)
return 1;
return 0;
}
if(me.pressed)
{
me.dragScrollPos = pos;
- p = me.scrollPos + pos_x - me.keepspaceLeft;
+ p = me.scrollPos + pos.x - me.keepspaceLeft;
me.cursorPos = draw_TextLengthUpToWidth(me.text, p, 0, me.realFontSize);
me.lastChangeTime = time;
}
if(me.cb_pressed)
if (over_ClearButton(me, pos))
{
+ m_play_click_sound(MENU_SOUND_CLEAR);
+ me.setText(me, "");
me.cb_pressed = 0;
- InputBox_Clear_Click(world, me);
return 1;
}
float r = InputBox_mouseDrag(me, pos);
case K_KP_DEL:
case K_DEL:
if(shift & S_CTRL)
+ {
+ m_play_click_sound(MENU_SOUND_CLEAR);
me.setText(me, "");
+ }
else
me.setText(me, strcat(substring(me.text, 0, me.cursorPos), substring(me.text, me.cursorPos + 1, strlen(me.text) - me.cursorPos - 1)));
return 1;
w = draw_TextWidth(strcat(ch, ch2), 0, me.realFontSize);
if(ch2 == "^")
{
- draw_Fill(p, eX * w + eY * me.realFontSize_y, '1 1 1', 0.5);
+ draw_Fill(p, eX * w + eY * me.realFontSize.y, '1 1 1', 0.5);
draw_Text(p + eX * 0.25 * w, "^", me.realFontSize, theColor, theAlpha, 0);
}
else if(ch2 == "0" || stof(ch2)) // digit?
case 8: theColor = '1 1 1'; theAlpha = 0.5; break;
case 9: theColor = '0.5 0.5 0.5'; theAlpha = 1; break;
}
- draw_Fill(p, eX * w + eY * me.realFontSize_y, '1 1 1', 0.5);
+ draw_Fill(p, eX * w + eY * me.realFontSize.y, '1 1 1', 0.5);
draw_Text(p, strcat(ch, ch2), me.realFontSize, theColor, theAlpha, 0);
}
else if(ch2 == "x") // ^x found
component = HEXDIGIT_TO_DEC(substring(me.text, i+2, 1));
if (component >= 0) // ^xr found
{
- theTempColor_x = component/15;
+ theTempColor.x = component/15;
component = HEXDIGIT_TO_DEC(substring(me.text, i+3, 1));
if (component >= 0) // ^xrg found
{
- theTempColor_y = component/15;
+ theTempColor.y = component/15;
component = HEXDIGIT_TO_DEC(substring(me.text, i+4, 1));
if (component >= 0) // ^xrgb found
{
- theTempColor_z = component/15;
+ theTempColor.z = component/15;
theColor = theTempColor;
w = draw_TextWidth(substring(me.text, i, 5), 0, me.realFontSize);
- draw_Fill(p, eX * w + eY * me.realFontSize_y, '1 1 1', 0.5);
+ draw_Fill(p, eX * w + eY * me.realFontSize.y, '1 1 1', 0.5);
draw_Text(p, substring(me.text, i, 5), me.realFontSize, theColor, 1, 0); // theVariableAlpha instead of 1 using alpha tags ^ax
i += 3;
}
{
// blue missing
w = draw_TextWidth(substring(me.text, i, 4), 0, me.realFontSize);
- draw_Fill(p, eX * w + eY * me.realFontSize_y, eZ, 0.5);
+ draw_Fill(p, eX * w + eY * me.realFontSize.y, eZ, 0.5);
draw_Text(p, substring(me.text, i, 4), me.realFontSize, '1 1 1', theAlpha, 0);
i += 2;
}
{
// green missing
w = draw_TextWidth(substring(me.text, i, 3), 0, me.realFontSize);
- draw_Fill(p, eX * w + eY * me.realFontSize_y, eY, 0.5);
+ draw_Fill(p, eX * w + eY * me.realFontSize.y, eY, 0.5);
draw_Text(p, substring(me.text, i, 3), me.realFontSize, '1 1 1', theAlpha, 0);
i += 1;
}
{
// red missing
//w = draw_TextWidth(substring(me.text, i, 2), 0) * me.realFontSize_x;
- draw_Fill(p, eX * w + eY * me.realFontSize_y, eX, 0.5);
+ draw_Fill(p, eX * w + eY * me.realFontSize.y, eX, 0.5);
draw_Text(p, substring(me.text, i, 2), me.realFontSize, '1 1 1', theAlpha, 0);
}
}
else
{
- draw_Fill(p, eX * w + eY * me.realFontSize_y, '1 1 1', 0.5);
+ draw_Fill(p, eX * w + eY * me.realFontSize.y, '1 1 1', 0.5);
draw_Text(p, strcat(ch, ch2), me.realFontSize, theColor, theAlpha, 0);
}
p += w * eX;