wargroundscanberra:character_sheet
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wargroundscanberra:character_sheet [2024/07/21 23:43] – [To do] curufea | wargroundscanberra:character_sheet [2024/08/30 15:32] (current) – curufea | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Character Sheets ====== | ====== Character Sheets ====== | ||
| ^ Go back to [[start|Wargrounds Canberra]] | ^ Go back to [[start|Wargrounds Canberra]] | ||
| + | |||
| + | |||
| + | ===== No Longer Used ===== | ||
| + | This project has been superseded by NanDeck (makes it much easier). But I'll keep it on my website just because it was fun to do. | ||
| + | |||
| + | ==== Forms ==== | ||
| * Working Form: [[form|Fill in Character Sheet]] | * Working Form: [[form|Fill in Character Sheet]] | ||
| * Working Location: [[https:// | * Working Location: [[https:// | ||
| - | * Test Form: [[form test|Fill in Character Sheet]] | + | * Test (same as working) |
| - | * Test Location: [[https:// | + | * Form: [[form test|Fill in Character Sheet]] |
| + | * Location: [[https:// | ||
| + | |||
| + | ==== Code ==== | ||
| <code php> | <code php> | ||
| <?php | <?php | ||
| // Character Sheet creator for Wargrounds Canberra | // Character Sheet creator for Wargrounds Canberra | ||
| - | // Version 1 22/7/24 - curufea@yahoo.com | + | // Version 1.5 20/8/24 - curufea@yahoo.com |
| // Currently hosted at www.curufea.com | // Currently hosted at www.curufea.com | ||
| Line 32: | Line 41: | ||
| $borderwidth = round($width/ | $borderwidth = round($width/ | ||
| $fontborder = round($borderwidth/ | $fontborder = round($borderwidth/ | ||
| + | $textlength = 30; | ||
| // default placeholder photo to be replaced by image from form url | // default placeholder photo to be replaced by image from form url | ||
| Line 46: | Line 56: | ||
| // array of default field names | // array of default field names | ||
| $names = array( | $names = array( | ||
| - | " | + | " |
| // the field names used in the form | // the field names used in the form | ||
| $getnames = array( | $getnames = array( | ||
| - | " | + | " |
| + | // 0 | ||
| - | // 400px x 400px jpeg images stored on the image path (in the Dokuwiki media area) | + | |
| - | $factions_images = array( | + | // 400px x 400px jpeg images stored on the image path (in the Dokuwiki media area) for faction logos |
| - | "clans.jpg", "empire.jpg", "greyscales.jpg", " | + | $factions_images = array(" |
| // used to cross reference the form data to the image name (the Bureaucracy plugin for the Dokuwiki doesn' | // used to cross reference the form data to the image name (the Bureaucracy plugin for the Dokuwiki doesn' | ||
| - | $factions_titles = array( | + | $factions_titles = array(" |
| - | "The Clans", | + | // 2987px x 4250px jpeg images stored on the image path (in the Dokuwiki media area) for faction backgrounds |
| - | + | $factions_backgrounds | |
| - | // test data - note will need some error checking | + | |
| - | $player_data | + | |
| - | "Peter", "Cousin Curufea", "", | + | |
| - | ); | + | |
| // count number of field names | // count number of field names | ||
| $numnames = count($names)-1; | $numnames = count($names)-1; | ||
| - | |||
| // As it is used multiple times, make the font border thingy a function | // As it is used multiple times, make the font border thingy a function | ||
| Line 71: | Line 78: | ||
| for ($x1=($start_x-$font_border); | for ($x1=($start_x-$font_border); | ||
| for ($y1=($start_y-$font_border); | for ($y1=($start_y-$font_border); | ||
| - | imagettftext($im, | + | // imagettftext($im, |
| }; | }; | ||
| }; | }; | ||
| }; | }; | ||
| - | |||
| - | |||
| // check if any variables have been sent to this image - if they have, overwrite the default player data | // check if any variables have been sent to this image - if they have, overwrite the default player data | ||
| for ($count=0; | for ($count=0; | ||
| | | ||
| // Convert the text of the selection for faction to a number | // Convert the text of the selection for faction to a number | ||
| - | if ($count==9) { | + | if ($count==6) { |
| | | ||
| - | | + | |
| }; | }; | ||
| }; | }; | ||
| Line 112: | Line 117: | ||
| $showstuff = true; // by default show all fields | $showstuff = true; // by default show all fields | ||
| + | |||
| + | // Add weapons to the character Sheet if there' | ||
| + | if (strlen($player_data[9])+strlen($player_data[10])==0) { | ||
| + | $im6 = imageCreateFromPng($weapons); | ||
| + | imagecopyresized($image, | ||
| + | imagedestroy($im6); | ||
| + | }; | ||
| + | |||
| + | // Add coin piles to the character Sheet | ||
| + | $im5 = imageCreateFromPng($coins); | ||
| + | if (strlen($player_data[7])> | ||
| + | imagecopyresized($image, | ||
| + | } else { | ||
| + | imagecopyresized($image, | ||
| + | }; | ||
| + | imagedestroy($im5); | ||
| + | |||
| + | // Add the large W | ||
| + | imagettftext($image, | ||
| for ($count=0; | for ($count=0; | ||
| $y=$y+$linespacing; | $y=$y+$linespacing; | ||
| - | // Clunky bit to do positioning. | + | // Clunky bit to do positioning. |
| - | if ($count==3||$count==7) $y=$y+$linespacing; | + | if ($count==3||$count==4) $y=$y+$linespacing; |
| - | if ($count==9) { // right column | + | if ($count==6) { // right column |
| $y= $linespacing*5; | $y= $linespacing*5; | ||
| $x= round($width/ | $x= round($width/ | ||
| }; | }; | ||
| - | if ($count==$numnames) { // centre the last text in the right column | + | if ($count==8) { // centre the last text in the right column |
| $text = $names[$count] . " 999"; // add possible length | $text = $names[$count] . " 999"; // add possible length | ||
| $text_box = imagettfbbox($fontsize, | $text_box = imagettfbbox($fontsize, | ||
| Line 131: | Line 155: | ||
| $y=$y+$linespacing; | $y=$y+$linespacing; | ||
| }; | }; | ||
| + | |||
| + | if ($count==9) { // Do the new Fletching field | ||
| + | $y=$fontsize+($linespacing*10); | ||
| + | $x = $fontsize; | ||
| + | }; | ||
| + | |||
| + | if ($count==10) { // Do the new background field | ||
| + | $y=$fontsize+($linespacing*12); | ||
| + | $x = $fontsize; | ||
| + | }; | ||
| // Player data in olde english font | // Player data in olde english font | ||
| Line 137: | Line 171: | ||
| $text = $player_data[$count]; | $text = $player_data[$count]; | ||
| - | // Hide the magic field if it isn't filled in | + | // Hide the magic, fletching and background fields |
| - | if (($count==8) and strlen($text)< | + | if (($count==5) and strlen($text)< |
| + | if (($count==9) and strlen($text)< | ||
| + | if (($count==10) and strlen($text)< | ||
| // Do the border for the field names | // Do the border for the field names | ||
| Line 149: | Line 185: | ||
| // Change the selected faction to readable text (and add faction logo) | // Change the selected faction to readable text (and add faction logo) | ||
| - | if ($count==9) { | + | if ($count==6) { |
| $text = $factions_titles[intval($player_data[$count])]; | $text = $factions_titles[intval($player_data[$count])]; | ||
| $faction= $imagepath.$factions_images[intval($player_data[$count])]; | $faction= $imagepath.$factions_images[intval($player_data[$count])]; | ||
| - | $im3 = imagecreatefromjpeg("$faction"); // Put in the faction logo | + | $im3 = imageCreateFromPng($faction); |
| - | imagecopyresized($image, | + | $ratio = imagesy($im3)/ |
| + | imagecopyresized($image, | ||
| imagedestroy($im3); | imagedestroy($im3); | ||
| }; | }; | ||
| Line 159: | Line 196: | ||
| // Print the data | // Print the data | ||
| - | // Put magic type on the next line so it fits | + | // Put titles, |
| - | if ($count==8) { | + | if (($count==5) or ($count==9)or ($count==10)) { |
| - | DoFontBorder ($image, | + | if ($count==10) { |
| - | imagettftext($image, | + | $maxlen=25; |
| + | $shorter = explode(" | ||
| + | $currentlength=0; | ||
| + | $currentline=1; | ||
| + | $currentword=0; | ||
| + | $text=""; | ||
| + | for ($wordcount=0; | ||
| + | $currentlength=$currentlength+strlen($shorter[$wordcount]); | ||
| + | $text=$text.$shorter[$wordcount]." | ||
| + | if ($currentlength> | ||
| + | $currentlength=0; | ||
| + | if ($currentline< | ||
| + | DoFontBorder ($image,round($fontsize*3/4),$x,$y+(round($linespacing/ | ||
| + | imagettftext($image, | ||
| + | }; | ||
| + | $text=""; | ||
| + | $currentline++; | ||
| + | }; | ||
| + | }; | ||
| + | } else { | ||
| + | DoFontBorder ($image, | ||
| + | imagettftext($image, | ||
| + | }; | ||
| } else { | } else { | ||
| - | if ($count==7) { // make class and tier smaller to fit | + | if (($count==2) or ($count==4) or ($count==7)) { // make titles, |
| - | | + | $maxlen=15; |
| - | imagettftext($image, | + | if ($count==2) $maxlen=25; |
| + | if (strlen($text)> | ||
| + | $string_break=stripos($text," | ||
| + | if (strlen($text)> | ||
| + | DoFontBorder ($image, | ||
| + | DoFontBorder ($image, | ||
| + | imagettftext($image, | ||
| + | imagettftext($image, | ||
| + | } else { | ||
| + | DoFontBorder ($image, | ||
| + | imagettftext($image, | ||
| + | }; | ||
| } else { | } else { | ||
| DoFontBorder ($image, | DoFontBorder ($image, | ||
| Line 176: | Line 246: | ||
| // Add the photo to the character Sheet | // Add the photo to the character Sheet | ||
| $im4 = imagecreatefromjpeg($photo); | $im4 = imagecreatefromjpeg($photo); | ||
| - | // Draw border | + | $ratio = imagesy($im4)/imagesx($im4); // Try to keep the photo in the same aspect ratio |
| - | imagefilledrectangle($image, round($width/1.8), round($width/1.5), round($width*31/32), round($width*6/16+$width), $fontcolour); | + | |
| - | // Resize and place in character Sheet | + | $start_x=round($width/ |
| - | imagecopyresized($image, | + | $start_y= |
| - | imagedestroy($im4); | + | |
| - | // Add coin piles to the character Sheet | + | $i_width= round($width*0.4); |
| - | $im5 = imageCreateFromPng($coins); | + | $i_height= |
| - | imagecopyresized($image, | + | |
| - | imagedestroy($im5); | + | |
| - | // Add weapons to the character Sheet | + | $end_x= $start_x+$i_width; |
| - | $im6 = imageCreateFromPng($weapons); | + | $end_y= |
| - | imagecopyresized($image,$im6, $linespacing*2, | + | |
| - | imagedestroy($im6); | + | |
| - | // Add the large W | + | // Draw border |
| - | imagettftext($image, $fontsize*3, 0, round($width*0.8), round($width/6), $fontcolour, $font_wargrounds, " | + | imagefilledrectangle($image,$start_x-$borderwidth,$start_y-$borderwidth,$end_x+$borderwidth, |
| + | |||
| + | // Resize and place in character Sheet | ||
| + | imagecopyresized($image, $im4, $start_x, $start_y, 0,0, $i_width, $i_height, imagesx($im4), imagesy($im4)); | ||
| + | imagedestroy($im4); | ||
| // tell the browser that the content is an image | // tell the browser that the content is an image | ||
| Line 207: | Line 275: | ||
| </ | </ | ||
| - | ===== To do ===== | ||
| - | |||
| - | * Possibly API use for wherever photos get stored (or just upload them) - may need to edit photos to fit | ||
wargroundscanberra/character_sheet.1721630632.txt.gz · Last modified: by curufea
