Latest Posts

Topic: Same player shout again

Atanase
Avatar
Topic Opener
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-19, 15:56

Hello,

Yes, I'm back for new questions.

I'm trying to use the function "campaign_message_with_objective(message, objective[, sleeptime])"

I saw, in other tutorial, how to use it for the stock windows, but I want to use it for the economy windows
I have the example of :

local o = campaign_message_with_objective(inventory1, obj_open_inventory)  
    while not mv.windows.stock_menu do sleep(200) end  
    set_objective_done(o, wl.Game().real_speed)   

in the mission_thread.lua and

 inventory1 = {  
    position = "topright",  
    title = _"Stock",  
    body = (  
        h1(_[[Check for Stock]]) ..  
        p(_[[Let’s see what we still have in stock.]])  
    )}  
obj_open_inventory = {  
    name = "open_inventory",  
    title=_"Open your stock window",  
    number = 1,  
    body = objective_text(_"Open your stock window",  
        p(_[[The stock window gives you an overview over the wares you currently have.]]) ..  
        li_image("images/wui/menus/statistics.png", _[[First, you will have to open the ‘Statistics’ menu at the bottom of the screen.]]) ..  
        li_image("images/wui/menus/statistics_stock.png", _[[Afterwards, choose ‘Stock’.]]) ..  
        li_arrow(_[[You can also use the hotkey ‘i’ (as in ‘inventory’) to access this window quickly.]])  
    )}  

in texts_lua. (not too easy to switch from one to the other each time I change a coma.)

Questions:
For the Stock window, the name is window.stock_menu (I suppose), what is the name for the Economy window? And more generally for all the windows we can open in the game.
Where can I find pics, like statistics.png and statistics_stock.png, for the flag and the Economy button. I searched ..../images/wui/* but couldn't find a flag.
If I put a screen copy of these button in the pics directory, how can I show them (what is the path)? ../pics/xxxx.png? Is it possible to open and to close a windows in the lua script directly?

I'm so sorry to bother you with all of these questions, but be sure I spent a lot of time looking right and left. In particular in the Development / Documentation section.

I think my idea of ​​making a well-commented and documented skeleton for use by apprentice coders is not so bad. face-wink.png

Oups.... it is ....shoot again and not ...shout... crazy frenchy.

Edited: 2021-04-19, 15:57

La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-04-19, 16:13

The name of a window can only be found by digging through the C++ code. The economy options window is called "economy_options" which is defined here. Similarly, the stock menu is called "stock_menu" defined here.

Images paths are relative to the Widelands data directory. You can also include custom images in the map's "pics" directory and reference them as "map:FILENAME.png" (where the FILENAME is relative to the pics dir).

Some flags can be found in "data/images/wui/fieldaction/menu_build_flag.png" (generic flag) or "data/tribes/initialization/<tribename>/images/<…>.png". Note that such paths may differ between Widelands versions.

Is it possible to open and to close a windows in the lua script directly?

You can access and click the toolbar buttons and dropdowns via scripting. Take a look at the 1st tutorial, and also the UI testsuite (test/maps/plain.wmf/scripting/test_ui.lua, test/maps/lua_testsuite.wmf/scripting/*). Run the testsuite scenarios from the commandline to view them (instructions), I guess they illustrate everything you need.

Edited: 2021-04-19, 16:21

Top Quote
Atanase
Avatar
Topic Opener
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-19, 17:43

Thank you very, very much.

I did the 4 tutorials and 3 campaigns out of the 4, plus 3 or 4 other maps. I must admit that I had totally forgotten that the 1st tutorial did what I wanted. All my excuses. It's perfect for me, just what I wanted. Thanks again.

Thanks also for being Master Miner while digging into C ++ code. face-wink.png


La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote