#ifdef INTERFACE CLASS(VoretInputBox) EXTENDS(InputBox) METHOD(VoretInputBox, configureVoretInputBox, void(entity, float, string)) METHOD(VoretInputBox, focusLeave, void(entity)) METHOD(VoretInputBox, setText, void(entity, string)) ATTRIB(VoretInputBox, fontSize, float, SKINFONTSIZE_NORMAL) ATTRIB(VoretInputBox, image, string, SKINGFX_INPUTBOX) ATTRIB(VoretInputBox, onChange, void(entity, entity), SUB_Null) ATTRIB(VoretInputBox, onChangeEntity, entity, NULL) ATTRIB(VoretInputBox, onEnter, void(entity, entity), SUB_Null) ATTRIB(VoretInputBox, onEnterEntity, entity, NULL) ATTRIB(VoretInputBox, marginLeft, float, SKINMARGIN_INPUTBOX_CHARS) ATTRIB(VoretInputBox, marginRight, float, SKINMARGIN_INPUTBOX_CHARS) ATTRIB(VoretInputBox, color, vector, SKINCOLOR_INPUTBOX_N) ATTRIB(VoretInputBox, colorF, vector, SKINCOLOR_INPUTBOX_F) ATTRIB(VoretInputBox, alpha, float, SKINALPHA_TEXT) ATTRIB(VoretInputBox, cvarName, string, string_null) METHOD(VoretInputBox, loadCvars, void(entity)) METHOD(VoretInputBox, saveCvars, void(entity)) METHOD(VoretInputBox, keyDown, float(entity, float, float, float)) ENDCLASS(VoretInputBox) entity makeVoretInputBox(float, string); #endif #ifdef IMPLEMENTATION entity makeVoretInputBox(float doEditColorCodes, string theCvar) { entity me; me = spawnVoretInputBox(); me.configureVoretInputBox(me, doEditColorCodes, theCvar); return me; } void configureVoretInputBoxVoretInputBox(entity me, float doEditColorCodes, string theCvar) { me.configureInputBox(me, "", 0, me.fontSize, me.image); me.editColorCodes = doEditColorCodes; if(theCvar) { me.cvarName = theCvar; me.tooltip = getZonedTooltipForIdentifier(theCvar); me.loadCvars(me); } me.cursorPos = strlen(me.text); } void focusLeaveVoretInputBox(entity me) { me.saveCvars(me); } void setTextVoretInputBox(entity me, string new) { if(me.text != new) { setTextInputBox(me, new); me.onChange(me, me.onChangeEntity); } else setTextInputBox(me, new); } void loadCvarsVoretInputBox(entity me) { if not(me.cvarName) return; setTextInputBox(me, cvar_string(me.cvarName)); } void saveCvarsVoretInputBox(entity me) { if not(me.cvarName) return; cvar_set(me.cvarName, me.text); } float keyDownVoretInputBox(entity me, float key, float ascii, float shift) { float r; r = 0; if(key == K_ENTER) { if(me.cvarName) { me.saveCvars(me); r = 1; } me.onEnter(me, me.onEnterEntity); } if(keyDownInputBox(me, key, ascii, shift)) r = 1; return r; } #endif