PDA

View Full Version : Menu Function - origin problem



RobsoN
4th July 2013, 16:25
Hello, I used this (http://killtube.org/showthread.php?1082-CoD2-create-functions-in-menu-files!&highlight=menu) tutorials for menu functions.

I've got error like that:
328

It's something bad with first argument.
Line in error message (185) is this line:


BUTTON_TITLE(ORIGIN_TITLE_1, "robson_title_locked", "ui_robson_list_1", "-2");


And the function:




#define ORIGIN_TITLE_1 220 130
#define ORIGIN_TITLE_2 220 190
#define ORIGIN_TITLE_3 220 250
#define ORIGIN_TITLE_4 220 310

#define ORIGIN_TITLE_5 420 130
#define ORIGIN_TITLE_6 420 190
#define ORIGIN_TITLE_7 420 250
#define ORIGIN_TITLE_8 420 310

#define BUTTON_TITLE(_origin, _image, _dvartest, _id) \
itemDef \
{ \
name "titles" \
origin _origin \
visible 1 \
rect 0 0 128 32 \
forecolor GLOBAL_UNFOCUSED_COLOR \
type ITEM_TYPE_BUTTON \
style WINDOW_STYLE_SHADER \
background _image \
dvartest _dvartest \
showDvar { "title_" ## _id } \
mouseEnter \
{ \
play "mouse_over"; \
} \
action \
{ \
play "mouse_click"; \
scriptmenuresponse "select_" ## _id; \
} \
}

I tried aslo


BUTTON_TITLE(220 130, "robson_title_locked", "ui_robson_list_1", "-2");

but still got error.

Thanks for help.

kung foo man
4th July 2013, 16:34
Please try to add this for "rect":

HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN


Like:



rect 0 0 128 32 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN \


You can also use a macro in a macro. First declare it over your current macro:



#define RECT(_rect_) \
rect _rect_ HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN


So you can rewrite the failing line like:


RECT(0 0 128 32) \

RobsoN
4th July 2013, 16:45
So much respect for you mate!

I aslo found my mistake in ';' and rect should be above origin.

Macros rocks!

Tally
4th July 2013, 16:57
I posted about this - when using macros, all rectangles must have 6 parameters and not the usual 4. Otherwise, the game wont parse them properly, and it starts to read other parameters as part of the rectangle. Hence, why the error was telling you that it was expecting an integer but found "forecolor" instead - it was reading the next line down as part of the rectangle.