forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Sat Nov 18, 2017 4:30 am

All times are UTC




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: Sun Jun 09, 2013 11:37 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
There is a floodfill-algorithm on Github: https://code.google.com/p/canvas-floodfill/.
But I really have not much of a clue about JS, and I can't integrate this... :-)


Top
 Profile  
 
PostPosted: Sun Jun 09, 2013 4:24 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
I've read about these floodfill-algorithms as well, but actually on maps like the WWIV, floodfill won't be enough as parts of a territory aren't connected to each other.
Today I overworked my code a bit. Now the grey-out on a blank WWIV-map is performed 3s. I also implemented some code to avoid, that territories, which are already greyed-out or transparent, are checked or even colored again. The next order only needs 0.8 s on the map, as not much territories had to change there color.
On the Classic-map it works quite smoothly.

The key to achieve this was to not store the colors which belong to the territories that have to be greyed-out or make transparent in an array, but in an object (in js like a hash) with the colors as keys. This way many comparisons could be avoided and the runtime got down to less than the half.

If you'd like to test it, you can download this code:

Attachment:
interactive.zip [60.84 KiB]
Downloaded 124 times


It only works with the move-order so far. As it is not working that smoothly on large maps, I placed a button "G" which has to be toggled first to activate the feature.

I'll try to get it run even more smoothly. One way could be to combine this with a floodfill-algorithm.


Top
 Profile  
 
PostPosted: Sun Jun 09, 2013 6:54 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
This does not work here.
It opens a new window and fails to load the IAgetMap.php
Because it needs some more functions defined in header.php which it does not include.
If I include header.php in the IAgetMap.php there is a problem with the SQL. "Transaction isolation level can't be changed while a transaction is in progress"


Top
 Profile  
 
PostPosted: Mon Jun 10, 2013 3:16 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
If it opens a new window, then something went wrong during the loading of the colored map. Have you placed IAgetMap.php in the main directory? As php is a bit annoying concerning the paths for including other php-files, it won't work in an extra folder.
The file definitely doesn't use any functions defined in header.php, it uses only functions from the included files. If I include header.php I get same error, but it works without header.php.

If you have still problems, you can "disable" the script by entering the direct path for the colored map in line 82 in interactiveMap.js. IAgetMap.php only detects the variant and loads the colored map. If needed, it will also create a map, but the grey-out should work without it if any colored map is loaded.


Top
 Profile  
 
PostPosted: Tue Jun 18, 2013 7:18 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
Update:

- territory-grey-out completed
Attachment:
Bildschirmfoto 2013-06-18 um 21.00.48.png
Bildschirmfoto 2013-06-18 um 21.00.48.png [ 10.05 KiB | Viewed 2758 times ]


- alternative way to set orders with buttons on the map
Attachment:
Bildschirmfoto 2013-06-18 um 21.00.28.png
Bildschirmfoto 2013-06-18 um 21.00.28.png [ 8.8 KiB | Viewed 2758 times ]


- all files are now stored in one directory again ("[webdip-domain]/interactiveMap/")

The new features were heavily tested on the "WWIV" variant whose extra files are stored in "interactiveMap/doc/example/WWIV/". Read "interactiveMap/doc/README.txt" for more information about the files.


Changes for existing versions:

- all existing files are replaced by new files in the new folder (the downloaded folder), that should be placed in the main directory of you webdip-installation
- the paths in "board/orders/orderinterface.php"->jsLoadBoard() have to be changed from "javascript/interactive/[...]" to "../interactiveMap/javascript/[...]"


Attachments:
interactiveMap.zip [250.19 KiB]
Downloaded 152 times
Top
 Profile  
 
PostPosted: Wed Jun 19, 2013 6:19 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Very cool.
Will give this a try today.


Top
 Profile  
 
PostPosted: Wed Jun 19, 2013 6:41 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Hi tobi, you should test your map with the newest webdip version.

I still get the error "Fatal error: Call to undefined function l_r() in D:\xampp\htdocs\vDiplomacy\lib\variant.php on line 23"
and l_r(); is a new translate function used by the new webdip-code and it's defined in header.php.

For this to work I included header.php and disabled $DB = new Database(); in IAgetMap.php

It does grey-out all the territories at the moment, But giving orders work really great. Esp. with the new icons.


Top
 Profile  
 
PostPosted: Wed Jun 19, 2013 7:37 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
I completely forget that my webdip version is really out of date. :oops:

Here is my updated version:
Attachment:
interactiveMap.zip [250.2 KiB]
Downloaded 136 times


I included locales/layer.php, which defines l_r(), but expecting future changes your solution might be the better one.

Quote:
It does grey-out all the territories at the moment

The file has to be included in IAgetMapTerrDat.php as well. Then it should work fine! :)


Top
 Profile  
 
PostPosted: Wed Jun 19, 2013 8:14 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Thanks, works now.
And idea: if you need to select a unit to give it an order grey out all of the map but your own units. That way it's easier to find all your units on the map.
And congrats for your hard work. This is really a great addition.


Top
 Profile  
 
PostPosted: Wed Jun 19, 2013 8:34 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
Sleepcap wrote:
And idea: if you need to select a unit to give it an order grey out all of the map but your own units. That way it's easier to find all your units on the map.


This could be added in less than 5 seconds as it is already implemented for the retreat-phase (simply remove '(context.phase=="Retreats")&&' in 'resetOrder' in 'interactiveMapOrders.js'), but I'm not sure if this would really help players at all time. I assume greyed-out territories could be annoying when you plan complex orders with many units involved, but I could add a 'highlight own units' button which could be optional used.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group