forum.webdiplomacy.net

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

All times are UTC




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Changing the Unit Art
PostPosted: Tue Jul 24, 2012 9:51 pm 
Offline

Joined: Sun Jun 03, 2012 12:25 am
Posts: 10
I'm working on developing the map for a variant about set in 1700 Europe, at the time of the War of the Spanish Succession and the Great Northern War. I was wondering, would it be possible to replace the standard units with ones I drew so it doesn't look ridiculous for the time period?


Top
 Profile  
 
PostPosted: Wed Jul 25, 2012 12:12 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Yes. It's rater easy.
In drawmap.php you can point to another graphic for the map.
If you want to change the icons in the OrderInterface you need to load some custom Javascript code in Orderdiplomacy.php

The GreatLakes-variant does this. You can download the files to see how this works here:
http://www.vdiplomacy.com/files.php?variantID=77.

Oliver


Top
 Profile  
 
PostPosted: Wed Jul 25, 2012 4:47 pm 
Offline

Joined: Sun Jun 03, 2012 12:25 am
Posts: 10
Thanks! That's very helpful.


Top
 Profile  
 
PostPosted: Thu Jul 26, 2012 3:01 am 
Offline

Joined: Sun Jun 03, 2012 12:25 am
Posts: 10
Would it be possible to have different color units for each power instead of the color boxes? I'm having trouble adapting the units to a single color.


Top
 Profile  
 
PostPosted: Thu Jul 26, 2012 5:37 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Yes, but it's a bit more complicated.
1. You need to load each unit-graphic.
2. You need to figure out what country the unit belongs to as it gets drawn.

Here is the code from the WWIV-variant that takes care about the different icons:
Code:
class CustomCountryIcons_drawMap extends MoveFlags_drawMap
{
   // Arrays for the custom icons:
   protected $unit_c =array(); // An array to store the owner of each territory
   protected $army_c =array(); // Custom army icons
   protected $fleet_c=array(); // Custom fleet icons

   // Load custom icons (fleet and army) for each country
   protected function loadImages()
   {
      for ($i=1; $i<=count($GLOBALS['Variants'][VARIANTID]->countries); $i++) {
         $this->army_c[$i]  = $this->loadImage('variants/WWIV/resources/army' .$GLOBALS['Variants'][VARIANTID]->countries[$i-1].'.png');
         $this->fleet_c[$i] = $this->loadImage('variants/WWIV/resources/fleet'.$GLOBALS['Variants'][VARIANTID]->countries[$i-1].'.png');
      }
      parent::loadImages();
   }
   
   // Save the countryID for every colored Territory (and their coasts)
   public function colorTerritory($terrID, $countryID)
   {
      $terrName=$this->territoryNames[$terrID];
      $this->unit_c[$terrID]=$countryID;
      $this->unit_c[array_search($terrName. " (North Coast)" ,$this->territoryNames)]=$countryID;
      $this->unit_c[array_search($terrName. " (East Coast)"  ,$this->territoryNames)]=$countryID;
      $this->unit_c[array_search($terrName. " (South Coast)" ,$this->territoryNames)]=$countryID;
      $this->unit_c[array_search($terrName. " (West Coast)"  ,$this->territoryNames)]=$countryID;
      parent::colorTerritory($terrID, $countryID);
   }
   
   // Store the country if a unit needs to draw a flag for a custom icon.
   public function countryFlag($terrName, $countryID)
   {
      $this->unit_c[$terrName]=$countryID;
      parent::countryFlag($terrName, $countryID);
   }
   
   // Draw the custom icons:
   public function addUnit($terrID, $unitType)
   {
      $this->army  = $this->army_c[$this->unit_c[$terrID]];
      $this->fleet = $this->fleet_c[$this->unit_c[$terrID]];
      parent::addUnit($terrID, $unitType);
   }
   
}

Oliver


Top
 Profile  
 
PostPosted: Thu Jul 26, 2012 3:40 pm 
Offline

Joined: Sun Jun 03, 2012 12:25 am
Posts: 10
I think I'll try that, it doesn't really work otherwise.
Where would I put that bit of code?


Top
 Profile  
 
PostPosted: Fri Jul 27, 2012 9:16 pm 
Offline

Joined: Sun Jun 03, 2012 12:25 am
Posts: 10
I found this in variant.php, and I can't figure out what it is. I set it to 42 for now, but does it matter?

public $id = 42;
public $mapID = 42;


Top
 Profile  
 
PostPosted: Thu Aug 02, 2012 8:07 pm 
Offline

Joined: Fri Mar 23, 2012 11:15 am
Posts: 10
Yes, it does matter. The ID should be the ID of the game. If you set mapID=1 you'll get someone else's map instead. Same with 2,3,4,5,6,7 etc.

_________________
/* Developer of the upcoming 830 variant
/* http://lab.vdiplomacy.com/files.php?variantID=75
/*/


Top
 Profile  
 
PostPosted: Fri Aug 03, 2012 12:56 am 
Offline

Joined: Sun Jun 03, 2012 12:25 am
Posts: 10
KiNg Of DiPlOmAcY wrote:
Yes, it does matter. The ID should be the ID of the game. If you set mapID=1 you'll get someone else's map instead. Same with 2,3,4,5,6,7 etc.

So what should I put there to not get someone else's?


Top
 Profile  
 
PostPosted: Fri Aug 03, 2012 5:04 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
It depends who hosts your variant.
If you run this on your own server you use a free ID, if someone else run your variant he need to adjust this ID to his needs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  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