void UI_RegisterTextNode (uiBehaviour_t* behaviour) { behaviour->name = "text"; behaviour->extends = "abstractscrollable"; behaviour->manager = UINodePtr(new uiTextNode()); behaviour->extraDataSize = sizeof(EXTRADATA_TYPE); /* Current selected line */ UI_RegisterExtradataNodeProperty(behaviour, "lineselected", V_INT, textExtraData_t, textLineSelected); /* Text of the current selected line */ UI_RegisterExtradataNodeProperty(behaviour, "textselected", V_CVAR_OR_STRING, textExtraData_t, textSelected); /* One of the list TEXT_STANDARD, TEXT_LIST, TEXT_UFOPEDIA, TEXT_BUILDINGS, * TEXT_BUILDING_INFO, TEXT_RESEARCH, TEXT_RESEARCH_INFO, TEXT_POPUP, * TEXT_POPUP_INFO, TEXT_AIRCRAFT_LIST, TEXT_AIRCRAFT, TEXT_AIRCRAFT_INFO, * TEXT_MESSAGESYSTEM, TEXT_CAMPAIGN_LIST, TEXT_MULTISELECTION. * There are more IDs in use - see ui_data.h for an up-to-date list. * Display a shared content registered by the client code. */ UI_RegisterExtradataNodeProperty(behaviour, "dataid", V_UI_DATAID, textExtraData_t, dataID); /* Size between two lines. Default value is 0, in this case it use a line height according to the font size. */ UI_RegisterExtradataNodeProperty(behaviour, "lineheight", V_INT, textExtraData_t, lineHeight); /* Bigger size of the width replacing a tab character. */ UI_RegisterExtradataNodeProperty(behaviour, "tabwidth", V_INT, textExtraData_t, tabWidth); /* What to do with text lines longer than node width. Default is to wordwrap them to make multiple lines. * It can be LONGLINES_WRAP, LONGLINES_CHOP, LONGLINES_PRETTYCHOP */ UI_RegisterExtradataNodeProperty(behaviour, "longlines", V_INT, textExtraData_t, longlines); /* Number of visible line we can display into the node height. * Currently, it translate the scrollable property <code>viewSize</code> * @todo For a smooth scroll we should split that */ UI_RegisterExtradataNodeProperty(behaviour, "rows", V_INT, textExtraData_t, super.scrollY.viewSize); /* Number of lines contained into the node. * Currently, it translate the scrollable property <code>fullSize</code> * @todo For a smooth scroll we should split that */ UI_RegisterExtradataNodeProperty(behaviour, "lines", V_INT, textExtraData_t, super.scrollY.fullSize); /** Highlight each node elements when the mouse move over the node. * @todo delete it when its possible (need to create a textlist...) */ UI_RegisterExtradataNodeProperty(behaviour, "mousefx", V_BOOL, textExtraData_t, mousefx); Com_RegisterConstInt("LONGLINES_WRAP", LONGLINES_WRAP); Com_RegisterConstInt("LONGLINES_CHOP", LONGLINES_CHOP); Com_RegisterConstInt("LONGLINES_PRETTYCHOP", LONGLINES_PRETTYCHOP); }
void UI_RegisterBaseInventoryNode (uiBehaviour_t* behaviour) { behaviour->name = "baseinventory"; behaviour->extends = "container"; behaviour->manager = UINodePtr(new uiBaseInventoryNode()); behaviour->extraDataSize = sizeof(EXTRADATA_TYPE); /* Display/hide weapons. */ UI_RegisterExtradataNodeProperty(behaviour, "displayweapon", V_BOOL, baseInventoryExtraData_t, displayWeapon); /* Display/hide ammo. */ UI_RegisterExtradataNodeProperty(behaviour, "displayammo", V_BOOL, baseInventoryExtraData_t, displayAmmo); /* Display/hide out of stock items. */ UI_RegisterExtradataNodeProperty(behaviour, "displayunavailableitem", V_BOOL, baseInventoryExtraData_t, displayUnavailableItem); /* Sort the list to display in stock items on top of the list. */ UI_RegisterExtradataNodeProperty(behaviour, "displayavailableontop", V_BOOL, baseInventoryExtraData_t, displayAvailableOnTop); /* Display/hide ammo near weapons. */ UI_RegisterExtradataNodeProperty(behaviour, "displayammoofweapon", V_BOOL, baseInventoryExtraData_t, displayAmmoOfWeapon); /* Display/hide out of stock ammo near weapons. <code>displayammoofweapon</code> must be activated first. */ UI_RegisterExtradataNodeProperty(behaviour, "displayunavailableammoofweapon", V_BOOL, baseInventoryExtraData_t, displayUnavailableAmmoOfWeapon); /* Custom the number of column we must use to display items. */ UI_RegisterExtradataNodeProperty(behaviour, "columns", V_INT, baseInventoryExtraData_t, columns); /* Filter items by a category. */ UI_RegisterExtradataNodeProperty(behaviour, "filter", V_INT, baseInventoryExtraData_t, filterEquipType); /* Position of the vertical view (into the full number of elements the node contain) */ UI_RegisterExtradataNodeProperty(behaviour, "viewpos", V_INT, baseInventoryExtraData_t, scrollY.viewPos); /* Size of the vertical view (proportional to the number of elements the node can display without moving) */ UI_RegisterExtradataNodeProperty(behaviour, "viewsize", V_INT, baseInventoryExtraData_t, scrollY.viewSize); /* Full vertical size (proportional to the number of elements the node contain) */ UI_RegisterExtradataNodeProperty(behaviour, "fullsize", V_INT, baseInventoryExtraData_t, scrollY.fullSize); /* Called when one of the properties viewpos/viewsize/fullsize change */ UI_RegisterExtradataNodeProperty(behaviour, "onviewchange", V_UI_ACTION, baseInventoryExtraData_t, onViewChange); Com_RegisterConstInt("FILTER_S_PRIMARY", FILTER_S_PRIMARY); Com_RegisterConstInt("FILTER_S_SECONDARY", FILTER_S_SECONDARY); Com_RegisterConstInt("FILTER_S_HEAVY", FILTER_S_HEAVY); Com_RegisterConstInt("FILTER_S_MISC", FILTER_S_MISC); Com_RegisterConstInt("FILTER_S_ARMOUR", FILTER_S_ARMOUR); Com_RegisterConstInt("FILTER_CRAFTITEM", FILTER_CRAFTITEM); Com_RegisterConstInt("FILTER_UGVITEM", FILTER_UGVITEM); Com_RegisterConstInt("FILTER_AIRCRAFT", FILTER_AIRCRAFT); Com_RegisterConstInt("FILTER_DUMMY", FILTER_DUMMY); Com_RegisterConstInt("FILTER_DISASSEMBLY", FILTER_DISASSEMBLY); }
void UI_RegisterSpinnerNode (uiBehaviour_t *behaviour) { behaviour->name = "spinner"; behaviour->extends = "abstractvalue"; behaviour->manager = new uiSpinnerNode(); behaviour->extraDataSize = sizeof(EXTRADATA_TYPE); /* The size of the widget is uneditable. Fixed to 15x19. */ UI_RegisterOveridedNodeProperty(behaviour, "size"); /** * @brief Backround used to display the spinner. It is displayed in the center of the node. */ UI_RegisterExtradataNodeProperty(behaviour, "background", V_UI_SPRITEREF, EXTRADATA_TYPE, background); /** * @brief Top icon used to decorate the top button of the spinner. It is displayed in the center of the node. */ UI_RegisterExtradataNodeProperty(behaviour, "topIcon", V_UI_SPRITEREF, EXTRADATA_TYPE, topIcon); /** * @brief Sprite used to decorate the bottom button of the spinner. It is displayed in the center of the node. */ UI_RegisterExtradataNodeProperty(behaviour, "bottomIcon", V_UI_SPRITEREF, EXTRADATA_TYPE, bottomIcon); /** * @brief Spinner mode allow to change the input action of the spinner. * SPINNER_NORMAL is the default mode. With SPINNER_ONLY_INC anywhere it click on the node * it will increase the value. With SPINNER_ONLY_DEC anywhere it click on the node * it will decrease the value. */ UI_RegisterExtradataNodeProperty(behaviour, "mode", V_INT, EXTRADATA_TYPE, mode); Com_RegisterConstInt("SPINNER_NORMAL", NORMAL); Com_RegisterConstInt("SPINNER_ONLY_INC", ONLY_INCREASE); Com_RegisterConstInt("SPINNER_ONLY_DEC", ONLY_DECREASE); }
void UI_RegisterAbstractNode (uiBehaviour_t* behaviour) { behaviour->name = "abstractnode"; behaviour->isAbstract = true; behaviour->manager = UINodePtr(new uiLocatedNode()); /* Top-left position of the node */ UI_RegisterNodeProperty(behaviour, "pos", V_POS, uiNode_t, box.pos); /* Size of the node */ propertySize = UI_RegisterNodeProperty(behaviour, "size", V_POS, uiNode_t, box.size); /* Width of the node (see also <code>size</code>) */ propertyWidth = UI_RegisterNodeProperty(behaviour, "width", V_FLOAT, uiNode_t, box.size[0]); /* Height of the node (see also <code>size</code>) */ propertyHeight = UI_RegisterNodeProperty(behaviour, "height", V_FLOAT, uiNode_t, box.size[1]); /* Left position of the node (see also <code>pos</code>) */ UI_RegisterNodeProperty(behaviour, "left", V_FLOAT, uiNode_t, box.pos[0]); /* Top position of the node (see also <code>pos</code>) */ UI_RegisterNodeProperty(behaviour, "top", V_FLOAT, uiNode_t, box.pos[1]); /* If true, the node name is indexed into the window. We can access to the node with * the path "windowName#nodeName" */ UI_RegisterNodeProperty(behaviour, "indexed", V_BOOL, uiNode_t, indexed); /* If true, the node is not displayed nor or activatable. */ propertyInvis = UI_RegisterNodeProperty(behaviour, "invis", V_BOOL, uiNode_t, invis); /* If true, the node is disabled. Few nodes support it, fell free to request an update. */ UI_RegisterNodeProperty(behaviour, "disabled", V_BOOL, uiNode_t, disabled); /* If true, the node is not ''tangible''. We click through it, then it will not receive mouse event. */ UI_RegisterNodeProperty(behaviour, "ghost", V_BOOL, uiNode_t, ghost); /* Flashing effect. */ UI_RegisterNodeProperty(behaviour, "flash", V_BOOL, uiNode_t, flash); /* Speed of the flashing effect */ UI_RegisterNodeProperty(behaviour, "flashspeed", V_FLOAT, uiNode_t, flashSpeed); /* Border size we want to display. */ UI_RegisterNodeProperty(behaviour, "border", V_INT, uiNode_t, border); /* Padding size we want to use. Few node support it. */ UI_RegisterNodeProperty(behaviour, "padding", V_INT, uiNode_t, padding); /* Background color we want to display. */ UI_RegisterNodeProperty(behaviour, "bgcolor", V_COLOR, uiNode_t, bgcolor); /* Border color we want to display. */ UI_RegisterNodeProperty(behaviour, "bordercolor", V_COLOR, uiNode_t, bordercolor); /* * Used to set the position of the node when the parent use a layout manager. * Else it do nothing. * Available values are: LAYOUTALIGN_TOPLEFT, LAYOUTALIGN_TOP, LAYOUTALIGN_TOPRIGHT, * LAYOUTALIGN_LEFT, LAYOUTALIGN_MIDDLE, LAYOUTALIGN_RIGHT, LAYOUTALIGN_BOTTOMLEFT, * LAYOUTALIGN_BOTTOM, LAYOUTALIGN_BOTTOMRIGHT, LAYOUTALIGN_FILL. * Allowed value depend the layout manager used. The update to date list is into * ui_node_panel.c * @image html http://ufoai.org/wiki/images/Layout.png */ UI_RegisterNodeProperty(behaviour, "align", V_INT, uiNode_t, align); /* * Used share an int, only used by 1 behaviour * @todo move it to the right behaviour, delete it */ UI_RegisterNodeProperty(behaviour, "num", V_INT, uiNode_t, num); /* Tooltip we want to use. */ UI_RegisterNodeProperty(behaviour, "tooltip", V_CVAR_OR_LONGSTRING, uiNode_t, tooltip); /* Text the node will display. */ UI_RegisterNodeProperty(behaviour, "string", V_CVAR_OR_LONGSTRING, uiNode_t, text); /* Text font the node will use. * @todo use V_REF_OF_STRING when its possible ('font' is never a cvar). */ UI_RegisterNodeProperty(behaviour, "font", V_CVAR_OR_STRING, uiNode_t, font); /* Text color the node will use. */ UI_RegisterNodeProperty(behaviour, "color", V_COLOR, uiNode_t, color); /* Text color the node will use when something is selected. */ UI_RegisterNodeProperty(behaviour, "selectcolor", V_COLOR, uiNode_t, selectedColor); /* Flashing color */ UI_RegisterNodeProperty(behaviour, "flashcolor", V_COLOR, uiNode_t, flashColor); /* Alignement of the text into the node, or elements into blocks. */ UI_RegisterNodeProperty(behaviour, "contentalign", V_UI_ALIGN, uiNode_t, contentAlign); /* When <code>invis</code> property is false (default value); * this condition say if the node is visible or not. It use a script expression. */ UI_RegisterNodeProperty(behaviour, "visiblewhen", V_UI_IF, uiNode_t, visibilityCondition); /* Called when the user click with left button into the node. */ UI_RegisterNodeProperty(behaviour, "onclick", V_UI_ACTION, uiNode_t, onClick); /* Called when the user click with right button into the node. */ UI_RegisterNodeProperty(behaviour, "onrclick", V_UI_ACTION, uiNode_t, onRightClick); /* Called when the user click with middle button into the node. */ UI_RegisterNodeProperty(behaviour, "onmclick", V_UI_ACTION, uiNode_t, onMiddleClick); /* Called when the user use the mouse wheel over the node. */ UI_RegisterNodeProperty(behaviour, "onwheel", V_UI_ACTION, uiNode_t, onWheel); /* Called when the user use the mouse wheel up over the node. */ UI_RegisterNodeProperty(behaviour, "onwheelup", V_UI_ACTION, uiNode_t, onWheelUp); /* Called when the user use the mouse wheel down over the node. */ UI_RegisterNodeProperty(behaviour, "onwheeldown", V_UI_ACTION, uiNode_t, onWheelDown); /* Called when the mouse enter over the node. */ UI_RegisterNodeProperty(behaviour, "onmouseenter", V_UI_ACTION, uiNode_t, onMouseEnter); /* Called when the mouse go out of the node. */ UI_RegisterNodeProperty(behaviour, "onmouseleave", V_UI_ACTION, uiNode_t, onMouseLeave); /* Called when the internal content of the nde change. Each behaviour use it how they need it. * @todo Move it where it is need. */ UI_RegisterNodeProperty(behaviour, "onchange", V_UI_ACTION, uiNode_t, onChange); /* Special attribute only use into the node description to exclude part of the node * (see also <code>ghost</code>). Rectangle position is relative to the node. */ UI_RegisterNodeProperty(behaviour, "excluderect", V_UI_EXCLUDERECT, uiNode_t, firstExcludeRect); /* Remove all child from the node (only dynamic allocated nodes). */ UI_RegisterNodeMethod(behaviour, "removeallchild", UI_AbstractNodeCallRemovaAllChild); /* Create a new child with name and type. */ UI_RegisterNodeMethod(behaviour, "createchild", UI_AbstractNodeCallCreateChild); /* Delete the node and remove it from his parent. */ UI_RegisterNodeMethod(behaviour, "delete", UI_AbstractNodeCallDelete); /* Delete the node in x ms and remove it from his parent. */ UI_RegisterNodeMethod(behaviour, "deletetimed", UI_AbstractNodeCallDeleteTimed); /** @todo move it into common? */ Com_RegisterConstInt("ALIGN_UL", ALIGN_UL); Com_RegisterConstInt("ALIGN_UC", ALIGN_UC); Com_RegisterConstInt("ALIGN_UR", ALIGN_UR); Com_RegisterConstInt("ALIGN_CL", ALIGN_CL); Com_RegisterConstInt("ALIGN_CC", ALIGN_CC); Com_RegisterConstInt("ALIGN_CR", ALIGN_CR); Com_RegisterConstInt("ALIGN_LL", ALIGN_LL); Com_RegisterConstInt("ALIGN_LC", ALIGN_LC); Com_RegisterConstInt("ALIGN_LR", ALIGN_LR); /* some commands */ #ifdef DEBUG Cmd_AddCommand("debug_mnsetnodeproperty", UI_NodeSetProperty_f, "Set a node property"); Cmd_AddCommand("debug_mngetnodeproperty", UI_NodeGetProperty_f, "Get a node property"); #endif }
static void testConstInt (void) { const constListEntry_t list[] = { {"namespace::power", 1}, {"namespace::speed", 2}, {"namespace::accuracy", 3}, {"namespace::mind", 4}, {"namespace::close", 5}, {"namespace::heavy", 6}, {"namespace::assault", 7}, {"namespace::sniper", 8}, {"namespace::explosive", 9}, {"namespace::hp", 10}, {NULL, -1} }; const constListEntry_t list2[] = { {"namespace2::soldier", 0}, {"namespace2::scientist", 1}, {"namespace2::worker", 2}, {"namespace2::pilot", 3}, {NULL, -1} }; int out; Com_RegisterConstInt("namespace::variable", 1); CU_ASSERT(Com_UnregisterConstVariable("namespace::variable")); Com_RegisterConstInt("namespace::variable", 1); CU_ASSERT(Com_UnregisterConstVariable("namespace::variable")); Com_RegisterConstInt("namespace::variable2", 2); Com_RegisterConstInt("namespace::variable3", 3); Com_RegisterConstInt("namespace::variable4", 4); Com_RegisterConstInt("namespace::variable5", 5); Com_RegisterConstInt("namespace::variable6", 6); Com_RegisterConstInt("namespace2::variable2", 10); out = 0; CU_ASSERT_TRUE(Com_GetConstInt("namespace2::variable2", &out)); CU_ASSERT_EQUAL(out, 10); out = 0; CU_ASSERT_TRUE(Com_GetConstInt("namespace::variable2", &out)); CU_ASSERT_EQUAL(out, 2); out = 0; CU_ASSERT_TRUE(Com_GetConstInt("variable2", &out)); CU_ASSERT_EQUAL(out, 10); CU_ASSERT_STRING_EQUAL(Com_GetConstVariable("namespace", 2), "variable2"); CU_ASSERT(Com_UnregisterConstVariable("namespace2::variable2")); CU_ASSERT(Com_UnregisterConstVariable("namespace::variable2")); CU_ASSERT(Com_UnregisterConstVariable("namespace::variable3")); CU_ASSERT(Com_UnregisterConstVariable("namespace::variable4")); CU_ASSERT(Com_UnregisterConstVariable("namespace::variable5")); CU_ASSERT(Com_UnregisterConstVariable("namespace::variable6")); CU_ASSERT(!Com_UnregisterConstVariable("namespace::variable")); CU_ASSERT(!Com_UnregisterConstVariable("namespace::variable2")); CU_ASSERT(!Com_UnregisterConstVariable("namespace::variable3")); CU_ASSERT(!Com_UnregisterConstVariable("namespace::variable4")); CU_ASSERT(!Com_UnregisterConstVariable("namespace::variable5")); CU_ASSERT(!Com_UnregisterConstVariable("namespace::variable6")); Com_RegisterConstList(list); out = 0; CU_ASSERT_TRUE(Com_GetConstInt("sniper", &out)); CU_ASSERT_EQUAL(out, 8); CU_ASSERT_TRUE(Com_UnregisterConstList(list)); out = 0; CU_ASSERT_FALSE(Com_GetConstInt("sniper", &out)); Com_RegisterConstList(list2); Com_RegisterConstList(list); CU_ASSERT_TRUE(Com_UnregisterConstList(list)); out = 0; CU_ASSERT(Com_GetConstInt("pilot", &out)); CU_ASSERT_EQUAL(out, 3); Com_UnregisterConstList(list2); }
void UI_RegisterPanelNode (uiBehaviour_t *behaviour) { localBehaviour = behaviour; behaviour->extends = "abstractscrollable"; behaviour->name = "panel"; behaviour->extraDataSize = sizeof(EXTRADATA_TYPE); behaviour->draw = UI_PanelNodeDraw; behaviour->loaded = UI_PanelNodeLoaded; behaviour->doLayout = UI_PanelNodeDoLayout; behaviour->getClientPosition = UI_PanelNodeGetClientPosition; behaviour->propertyChanged = UI_PanelPropertyChanged; behaviour->scroll = UI_PanelNodeMouseWheel; /** * Select a layout manager to set position and size of child. Most of layout manager * do not move or resize child without align property set. In the image, number identify * the position of the child into node, and same color identify the same node. Text on child * display the value of the "align" property of each child. * <li>0: no layout manager. Child keep there position and there size. * <li>LAYOUT_TOP_DOWN_FLOW: layout child from top to down. Only child height do not change. * <li>LAYOUT_PACK: Pack one by one child into the available space of the node. * <li>LAYOUT_BORDER: Align nodes at a know position. Its look like pack layout, but the order is not the same. * top and bottom child first, then left and right, then middle. We can show the difference into the image. * <li>LAYOUT_STAR: Align the corner of child into the corner of the node. Child size do not change. * @image html http://ufoai.org/wiki/images/Layout.png */ UI_RegisterExtradataNodeProperty(behaviour, "layout", V_INT, panelExtraData_t, layout); /** * Margin use to layout children (margin between children) */ propertyLayoutMargin = UI_RegisterExtradataNodeProperty(behaviour, "layoutMargin", V_INT, panelExtraData_t, layoutMargin); /** * Number of column use to layout children (used with LAYOUT_COLUMN) */ propertyLayoutColumns = UI_RegisterExtradataNodeProperty(behaviour, "layoutColumns", V_INT, panelExtraData_t, layoutColumns); /** * If scrolling via mousewheel is enabled */ UI_RegisterExtradataNodeProperty(behaviour, "wheelscrollable", V_BOOL, panelExtraData_t, wheelScrollable); Com_RegisterConstInt("LAYOUTALIGN_TOPLEFT", LAYOUTALIGN_TOPLEFT); Com_RegisterConstInt("LAYOUTALIGN_TOP", LAYOUTALIGN_TOP); Com_RegisterConstInt("LAYOUTALIGN_TOPRIGHT", LAYOUTALIGN_TOPRIGHT); Com_RegisterConstInt("LAYOUTALIGN_LEFT", LAYOUTALIGN_LEFT); Com_RegisterConstInt("LAYOUTALIGN_MIDDLE", LAYOUTALIGN_MIDDLE); Com_RegisterConstInt("LAYOUTALIGN_RIGHT", LAYOUTALIGN_RIGHT); Com_RegisterConstInt("LAYOUTALIGN_BOTTOMLEFT", LAYOUTALIGN_BOTTOMLEFT); Com_RegisterConstInt("LAYOUTALIGN_BOTTOM", LAYOUTALIGN_BOTTOM); Com_RegisterConstInt("LAYOUTALIGN_BOTTOMRIGHT", LAYOUTALIGN_BOTTOMRIGHT); Com_RegisterConstInt("LAYOUTALIGN_FILL", LAYOUTALIGN_FILL); Com_RegisterConstInt("LAYOUT_TOP_DOWN_FLOW", LAYOUT_TOP_DOWN_FLOW); Com_RegisterConstInt("LAYOUT_LEFT_RIGHT_FLOW", LAYOUT_LEFT_RIGHT_FLOW); Com_RegisterConstInt("LAYOUT_BORDER", LAYOUT_BORDER); Com_RegisterConstInt("LAYOUT_PACK", LAYOUT_PACK); Com_RegisterConstInt("LAYOUT_STAR", LAYOUT_STAR); Com_RegisterConstInt("LAYOUT_CLIENT", LAYOUT_CLIENT); Com_RegisterConstInt("LAYOUT_COLUMN", LAYOUT_COLUMN); }