project-navigation
Personal tools

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - xray

Pages: 1 ... 3 4 [5]
61
Coding / Re: lua design thoughts
« on: June 17, 2014, 03:39:02 pm »
I've recreated a small part of the file main.ufo into lua to show what it could look like in lua (see code snippet below). Added some comments to explain a bit what is happening. Feel free to post any comments on it.

As for the actual implementation. I'm planning to use SWIG to create the binding between lua and the ufo main C/C++ code. The advantage of this is, that should lua evolve (chances are it will), the SWIG tool will handle this. Also, SWIG provides binding implementation for multiple dynamic languages, so should the need arise to actually switch to another script language, it will be a lot easier to do.

xray

Code: [Select]
--[[
MAIN MENU
--]]

-- definitions of named colors (not present yet, names are illustrative)
-- contains entry: COLOR_DARK_YELLOW = [0.0, 0.5, 0.0, 1.0]
-- contains entry: COLOR_WHITE = [1.0, 1.0, 1.0, 1.0]
require ("_colors.ufo")

-- create title control
local lb_title = Label ("_UFO: ALIEN INVASION", 500, 50, 262, 50, "f_title", [0.59, 0.78, 0.56, 1.0], ALIGN_CC)

-- create facebook button
local btn_facebook = Button ("_Facebook", 10, 720, 80, 20, COLOR_DARK_YELLOW)
btn_facebook.tooltip = "_Like us on facebook"
btn_facebook.padding = 0
btn_facebook.selectcolor = [1, 1, 1, 1]

function btn_facebook:onClick ()
-- todo
end

-- create twitter button
local btn_twitter = Button ("_Twitter", 100, 720, 70, 20, COLOR_DARK_YELLOW)
btn_twitter.tooltip = "_Follow us on twitter"
btn_twitter.padding = 0
btn_twitter.selectcolor = COLOR_WHITE

function btn_twitter:onClick ()
-- todo
end

-- import a button defined in _assets.ufo.lua (the .lua is added automatically)
require ("_assets.ufo")

-- create button CAMPAIGN
local btn_campain = MainMenuBtn ("_CAMPAIGN")

function btn_campaign:onClick ()
-- todo
end

-- create buttons panel
local pnl_buttons = Panel ()
pnl_buttons.pos = [312, 250]
pnl_buttons.size = [400, 400]
pnl_buttons.layout = LAYOUT_TOP_DOWN_FLOW
pnl_buttons.layoutMargin = 15

-- create the main window
local main = Window ()
main.background = "ui/main_bg"
main:add (title)
main:add (btn_facebook)
main:add (btn_twitter)
main:add (pnl_buttons)

62
Coding / Re: error when compiling on win32 windows
« on: June 14, 2014, 07:16:48 pm »
Can confirm also it does not yet compile using the TDM-GCC-32. Problem here is also the libraries that are not part of the TDM-set. It generates link errors. If we want to use TDM as toolchain base, then we must have a separate package building libraries. As an alternative, the codeblocks.zip (containing C::B and the MinGW toolchain) could be updated. Actually, this one I think is the best solution

63
Coding / Re: error when compiling on win32 windows
« on: June 12, 2014, 10:26:22 pm »
I see.

Removing the compiler flag C++11 did help. I can now compile the game.dll. Other projects however suffer from a missing ddraw.h file. I checked the old mingw compiler (version 4.5.0). That version still included the ddraw.h. The new TDM compiler (version 4.8.1) doesn't include this file anymore. I guess it has to do with dropping the support of old directx versions (7/8). I can understand that.

I guess the best thing is to wait until these issues are solved. If you need some help testing just send me a message.

xray

64
Coding / error when compiling on win32 windows
« on: June 12, 2014, 08:30:47 pm »
Hi,

Since today I'm experiencing trouble with compiling the source. I first encounted a compile flag error (C++11 unsupported). I then checked the 'compile for windows' page. I followed the instructions to upgrade to TDM. However, since I'm working on a win32 platform I downloaded the 32-bit TDM version instead of the 64-bit mentioned.

Then compiled again to see the following errors

Code: [Select]
-------------- Build: windows in game (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -shared   -Wl,--dll -LZ:\_Development\Tools\TDM-MinGW\lib .objs\game\src\game\chr_shared.o .objs\game\src\game\g_actor.o .objs\game\src\game\g_ai.o .objs\game\src\game\g_ai_lua.o .objs\game\src\game\g_camera.o .objs\game\src\game\g_client.o .objs\game\src\game\g_cmds.o .objs\game\src\game\g_combat.o .objs\game\src\game\g_edicts.o .objs\game\src\game\g_events.o .objs\game\src\game\g_func.o .objs\game\src\game\g_health.o .objs\game\src\game\g_inventory.o .objs\game\src\game\g_main.o .objs\game\src\game\g_match.o .objs\game\src\game\g_mission.o .objs\game\src\game\g_morale.o .objs\game\src\game\g_move.o .objs\game\src\game\g_reaction.o .objs\game\src\game\g_round.o .objs\game\src\game\g_spawn.o .objs\game\src\game\g_stats.o .objs\game\src\game\g_svcmds.o .objs\game\src\game\g_trigger.o .objs\game\src\game\g_utils.o .objs\game\src\game\g_vis.o .objs\game\src\game\inv_shared.o .objs\game\src\game\inventory.o .objs\game\src\game\q_shared.o .objs\game\src\libs\lua\lapi.o .objs\game\src\libs\lua\lauxlib.o .objs\game\src\libs\lua\lbaselib.o .objs\game\src\libs\lua\lcode.o .objs\game\src\libs\lua\ldblib.o .objs\game\src\libs\lua\ldebug.o .objs\game\src\libs\lua\ldo.o .objs\game\src\libs\lua\ldump.o .objs\game\src\libs\lua\lfunc.o .objs\game\src\libs\lua\lgc.o .objs\game\src\libs\lua\linit.o .objs\game\src\libs\lua\liolib.o .objs\game\src\libs\lua\llex.o .objs\game\src\libs\lua\lmathlib.o .objs\game\src\libs\lua\lmem.o .objs\game\src\libs\lua\loadlib.o .objs\game\src\libs\lua\lobject.o .objs\game\src\libs\lua\lopcodes.o .objs\game\src\libs\lua\loslib.o .objs\game\src\libs\lua\lparser.o .objs\game\src\libs\lua\lstate.o .objs\game\src\libs\lua\lstring.o .objs\game\src\libs\lua\lstrlib.o .objs\game\src\libs\lua\ltable.o .objs\game\src\libs\lua\ltablib.o .objs\game\src\libs\lua\ltm.o .objs\game\src\libs\lua\lua.o .objs\game\src\libs\lua\lundump.o .objs\game\src\libs\lua\lvm.o .objs\game\src\libs\lua\lzio.o .objs\game\src\libs\lua\print.o .objs\game\src\shared\aabb.o .objs\game\src\shared\infostring.o .objs\game\src\shared\mathlib.o .objs\game\src\shared\parse.o .objs\game\src\shared\shared.o .objs\game\src\shared\utf8.o  -o ..\..\base\game.dll 
.objs\game\src\game\g_cmds.o: In function `Z15G_ClientCommandR6Player':
Z:/_Development/Projects/Ufo/ufoai/src/game/g_cmds.cpp:442: undefined reference to `_stricmp(char const*, char const*)'
Z:/_Development/Projects/Ufo/ufoai/src/game/g_cmds.cpp:444: undefined reference to `_stricmp(char const*, char const*)'
Z:/_Development/Projects/Ufo/ufoai/src/game/g_cmds.cpp:446: undefined reference to `_stricmp(char const*, char const*)'
.objs\game\src\game\g_main.o: In function `CheckNeedPass':
Z:/_Development/Projects/Ufo/ufoai/src/game/g_main.cpp:305: undefined reference to `_stricmp(char const*, char const*)'
.objs\game\src\game\g_svcmds.o: In function `Z15G_ServerCommandv':
Z:/_Development/Projects/Ufo/ufoai/src/game/g_svcmds.cpp:354: undefined reference to `_stricmp(char const*, char const*)'
.objs\game\src\game\g_svcmds.o:Z:/_Development/Projects/Ufo/ufoai/src/game/g_svcmds.cpp:356: more undefined references to `_stricmp(char const*, char const*)' follow
.objs\game\src\shared\shared.o: In function `Z9Q_stristrPKcS0_':
Z:/_Development/Projects/Ufo/ufoai/src/shared/shared.cpp:571: undefined reference to `_strnicmp(char const*, char const*, unsigned int)'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
7 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I traced it to the file src\shared\shared.h:

Code: [Select]
/* portable case sensitive compare */
#if defined(_WIN32)
# define Q_strcasecmp(a, b) _stricmp((a), (b))
# define Q_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
#else
# define Q_strcasecmp(a, b) strcasecmp((a), (b))
# define Q_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n))
#endif

I then checked the flags for a _WIN32 flag. It wasn't there. Added it but this didn't solved the issue. Now I'm a bit lost.
It is a linker error. I'm compiling with the correct library paths. And I cannot see the error in the define.
Code: [Select]
_stricmp is perfectly legal C.

Plz. help!

xray

65
Coding / lua design thoughts
« on: June 11, 2014, 09:25:51 pm »
Hi,

I've created a fork of the master branch to begin replacing the current ui script language with lua.

Before getting into the coding, it's always good to have some thoughts about how the implementation should look like. That's what this post is for and I invite everyone to post ideas.

The goal is to bring lua in as a scripting language, replacing the current native script implementation found in the ui. I'll probably start with the ui-part since that's the area that'll benefit most.

One question I'd like to hear some views on is wether the implementation should be allowed to break the current scripts or that it should be additive. The first will lead to a full rewrite of the .ufo files, the second will allow a more evolutionary rewrite of .ufo files.

Another question is wether the lua language should be used for all the .ufo files, including those not dealing with the ui (e.g. campaigns.ufo, installations.ufo).

I'll be looking forward to any thoughts.

xray

66
Coding / Re: new ui script language: lua, angelscript, python???
« on: June 11, 2014, 09:07:02 pm »
OK.

I'll create a fork in git. I'm not sure how long it will take me to create a working implementation.
I've read the lua docs on this and looking at youre code I see a lot that looks familiair.

I'll also start a new topic on this to discuss some design issues.

xray

67
Coding / new ui script language: lua, angelscript, python???
« on: June 08, 2014, 08:08:43 am »
Hi,

I noticed in the todo-list an item to replace the current custom script language with a general purpose script language. AngelScript was mentioned as a candidate. I also find some references about lua and the AI, however, I cannot seem to locate where they are used in the codebase.

My question: is anyone actually using lua?

I'm interested in making a patch to the ui script base so that (next to the current custom script language) a second script language could be used. That way current ui-scripts would remain functional up to the point the new language is solid enough to replace it. If lua is already in view somehow, it would make sense to reuse it. There should be no need to implement multiple script language in the same game. If not, what language is preferred. Lua, AngelScript or something else (Python??).

Any thoughts?

xray

68
User modifications / Re: extension to ui script language
« on: June 01, 2014, 08:44:15 pm »
Hi Mattn,

Ah yes, sorry. I should have thought about that. The code below is from the file ui_actions.cpp.
Code: [Select]
/*
expected usage in .ufo scripts:

forchildin ( panel ) {
}
*/
case EA_FORCHILDIN:
{
uiNode_t* root;
root = UI_GetNodeFromExpression(action->d.nonTerminal.left, context, nullptr);

uiNode_t* node = root->firstChild;
int loop = 0;
while (node != root->lastChild) {
UI_ExecuteActions(action->d.nonTerminal.right, context);
if (context->breakLoop) {
context->breakLoop = false;
break;
}
if (loop > 1000) {
Com_Printf("UI_ExecuteAction: Infinite loop. Force breaking 'forchildin'\n");
break;
}
node = node->next;
loop++;
}
break;
}

Somewhere in the while loop, before UI_ExecuteActions(..) I have to create a variable that can be accessed from within the script that references the current value of
Code: [Select]
node. The attached 7z contains the modified files.

Regards,
xray


69
User modifications / extension to ui script language
« on: June 01, 2014, 04:58:12 pm »
Hi,

I've been working on some modifications to the ui script language. I've added implementation for a
Code: [Select]
forchildin keyword (a foreach that iterates child nodes of a given ui-node) and the
Code: [Select]
break statement to exit a loop. Now the code needs a last finishing touch. Inside the iterating body I need a way to reference the child node being visited. To do so, I guess I have to change the executing context of the action and add a hidden variable (something like self) that can be referenced from the code body of the iterating block. I cannot seem to figure out how to do this? Any help is appreciated.

Regards,
xray

70
For such functionality you need to write a C callback now. :(

I would be happy to see such a foreach loop possibility in the UI Engine though. If you could implement it, I would be happy to add it to the codebase!

This at least confirms what I already guessed. Unfortunately I only recently started looking at the code base, so I guess it will be a while before I actually have something working.

Based on you mentioning the "UI engine", are you proposing a 'foreach' solution in the script language? Would it not be easier to implement an iterator node that iterates the children of a target node and executes a confunc? This way, if you need an iterator you create a hidden node (e.g. the data node) and use it.

71
I was looking into the ui/*.ufo scripts, more specifically the scripts controlling the management of soldier equipment. I wanted to create a way to add the selected equipment to all soldiers in the soldierslist panel. However I seem to get stuck since I cannot figure out how to iterate the nodes in the panel. Is there a way to iterate a set of nodes? Are there any examples of this type of behaviour?

I appreciate any help/hints.

72
Feature Requests / soldier camouflage: change in a single action
« on: December 15, 2010, 07:22:14 pm »
Hi,

What a great game is this. Still, a minor improvement is possible. When in supplying the equipment to the soldiers, you can change the camouflage outfit. The funny thing is
that you have to switch camouflage for each soldier. Though it makes sense from the equipment point-of-view, I cannot imagine a situation where the camouflage of the soldiers
is different. Then again, it probably doesn't matter in combat what camouflage the soldiers wear.

On a more generic level. There are more items that could be added group. So you could add an option on the screen toggling wether the equipment you drag to a soldier is for one soldier or for all soldiers. If on, then dragging a grenade to a soldier will equip all soldiers with a grenade etc.

Regards
x-ray

Pages: 1 ... 3 4 [5]