Browse Source

working on decachunk generation and reading

master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
f276708063
  1. 72
      chunkymap-regen.py
  2. 237
      web/chunkymap.php
  3. BIN
      web/chunkymapdata_default/images/arrow-wide-down.png
  4. BIN
      web/chunkymapdata_default/images/arrow-wide-left.png
  5. BIN
      web/chunkymapdata_default/images/arrow-wide-right.png
  6. BIN
      web/chunkymapdata_default/images/arrow-wide-up.png
  7. BIN
      web/chunkymapdata_default/images/chunk-blank-fancy.jpg
  8. BIN
      web/chunkymapdata_default/images/chunk-blank.jpg
  9. BIN
      web/chunkymapdata_default/images/decachunk-blank-fancy.jpg
  10. BIN
      web/chunkymapdata_default/images/decachunk-blank.jpg
  11. 7
      web/example.php
  12. 12
      web/update wamp www.bat

72
chunkymap-regen.py

@ -390,7 +390,7 @@ class MTChunks:
python_exe_path = None python_exe_path = None
chunks = None chunks = None
decachunks = None decachunks = None
total_newly_rendered = None rendered_this_session_count = None
#region values for subprocess arguments: #region values for subprocess arguments:
pixelspernode = 1 pixelspernode = 1
@ -436,7 +436,7 @@ class MTChunks:
def __init__(self): #formerly checkpaths() in global scope def __init__(self): #formerly checkpaths() in global scope
self.min_indent = " " self.min_indent = " "
self.decachunks = {} self.decachunks = {}
self.total_newly_rendered = 0 self.rendered_this_session_count = 0
os_name="linux" os_name="linux"
if (os.path.sep!="/"): if (os.path.sep!="/"):
os_name="windows" os_name="windows"
@ -828,8 +828,8 @@ class MTChunks:
return "decachunk_"+self.get_decachunk_luid_from_decachunk(decachunky_x, decachunky_z)+".jpg" return "decachunk_"+self.get_decachunk_luid_from_decachunk(decachunky_x, decachunky_z)+".jpg"
def get_decachunk_luid_from_chunk(self, chunky_x, chunky_z): def get_decachunk_luid_from_chunk(self, chunky_x, chunky_z):
decachunky_x = int(math.floor(chunky_x/10)) decachunky_x = self.get_decachunky_coord_from_chunky_coord(chunky_x)
decachunky_z = int(math.floor(chunky_z/10)) decachunky_z = self.get_decachunky_coord_from_chunky_coord(chunky_z)
return self.get_chunk_luid(decachunky_x, decachunky_z) return self.get_chunk_luid(decachunky_x, decachunky_z)
def get_decachunk_luid_from_decachunk(self, decachunky_x, decachunky_z): def get_decachunk_luid_from_decachunk(self, decachunky_x, decachunky_z):
@ -856,24 +856,31 @@ class MTChunks:
def get_signal_path(self): def get_signal_path(self):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), self.get_signal_name()) return os.path.join(os.path.dirname(os.path.abspath(__file__)), self.get_signal_name())
def get_decachunky_coord_from_chunky_coord(self, chunky_x):
return int(math.floor(float(chunky_x)/10.0))
def check_decachunk_containing_chunk(self, chunky_x, chunky_z): def check_decachunk_containing_chunk(self, chunky_x, chunky_z):
chunk16_coord_list = list() chunk16_coord_list = list()
decachunky_x = int(math.floor(chunky_x/10)) decachunky_x = self.get_decachunky_coord_from_chunky_coord(chunky_x)
decachunky_z = int(math.floor(chunky_z/10)) decachunky_z = self.get_decachunky_coord_from_chunky_coord(chunky_z)
chunk16x_min = decachunky_x*10 chunk16x_min = decachunky_x*10
chunk16x_max = chunk16x_min + 15 # NOTE: + 15 even if negative since originally, floor was used chunk16x_max = chunk16x_min + 15 # NOTE: + 15 even if negative since originally, floor was used
chunk16z_min = decachunky_z*10 chunk16z_min = decachunky_z*10
chunk16z_max = chunk16z_min + 15 # NOTE: + 15 even if negative since originally, floor was used chunk16z_max = chunk16z_min + 15 # NOTE: + 15 even if negative since originally, floor was used
chunky_x_count=chunk16x_max-chunk16x_min+1
chunky_z_count=chunk16z_max-chunk16z_min+1
is_any_part_queued = False is_any_part_queued = False
chunky_z = chunk16x_min chunky_z = chunk16z_min
preview_strings = list()
while chunky_z <= chunk16z_max: while chunky_z <= chunk16z_max:
preview_strings.append("")
chunky_x = chunk16x_min chunky_x = chunk16x_min
while chunky_x <= chunk16x_max: while chunky_x <= chunk16x_max:
coords = (chunky_x, chunky_z) coords = (chunky_x, chunky_z)
chunk16_coord_list.append( coords ) chunk16_coord_list.append( coords )
if self.todo_index<len(self.todo_positions): if self.todo_index<len(self.todo_positions):
for index in range(self.todo_index,len(self.todo_positions)): for index in range(self.todo_index,len(self.todo_positions)):
if ivec2_equals(self.todo_positions[self.todo_index], coords): if ivec2_equals(self.todo_positions[index], coords):
is_any_part_queued = True is_any_part_queued = True
break break
if is_any_part_queued: if is_any_part_queued:
@ -883,17 +890,28 @@ class MTChunks:
break break
chunky_z += 1 chunky_z += 1
if not is_any_part_queued: if not is_any_part_queued:
print("")
print("")
print(" Rendering 160px decachunk "+str((decachunky_x, decachunky_z))) print(" Rendering 160px decachunk "+str((decachunky_x, decachunky_z)))
if self.verbose_enable:
print(" USING ("+str(len(chunk16_coord_list))+") chunks: "+str(chunk16_coord_list))
print("")
else:
print(" USING ("+str(len(chunk16_coord_list))+") chunks")
decachunk_global_coords = decachunky_x*160, decachunky_z*160 decachunk_global_coords = decachunky_x*160, decachunky_z*160
im = Image.new("RGB", (160, 160), self.FLAG_EMPTY_HEXCOLOR) im = Image.new("RGB", (160, 160), self.FLAG_EMPTY_HEXCOLOR)
decachunk_yaml_path = self.get_decachunk_yaml_path_from_decachunk(decachunky_x, decachunky_z) decachunk_yaml_path = self.get_decachunk_yaml_path_from_decachunk(decachunky_x, decachunky_z)
decachunk_image_path = self.get_decachunk_image_path_from_decachunk(decachunky_x, decachunky_z) decachunk_image_path = self.get_decachunk_image_path_from_decachunk(decachunky_x, decachunky_z)
combined_count = 0 combined_count = 0
contains_chunk_luids = list() contains_chunk_luids = list()
for coord in chunk16_coord_list: for coord in chunk16_coord_list:
chunky_x, chunky_z = coord chunky_x, chunky_z = coord
chunky_offset_x = chunky_x - chunk16x_min
chunky_offset_z = chunky_z - chunk16x_min
chunk_image_path = self.get_chunk_image_path(chunky_x, chunky_z) chunk_image_path = self.get_chunk_image_path(chunky_x, chunky_z)
if os.path.isfile(chunk_image_path): if os.path.isfile(chunk_image_path):
preview_strings[chunky_offset_z] += "1"
participle="initializing" participle="initializing"
try: try:
participle="opening path" participle="opening path"
@ -911,6 +929,14 @@ class MTChunks:
except: except:
print("Could not finish "+participle+" in check_decachunk_containing_chunk:") print("Could not finish "+participle+" in check_decachunk_containing_chunk:")
view_traceback() view_traceback()
else:
preview_strings[chunky_offset_z] += "0"
chunky_offset_z = chunky_z_count - 1
print(self.min_indent+"Usable chunk images mask:")
while chunky_offset_z>=0:
print(self.min_indent+" "+preview_strings[chunky_offset_z])
chunky_offset_z -= 1
print("")
decachunk_folder_path = self.get_decachunk_folder_path_from_decachunk(decachunky_x, decachunky_z) decachunk_folder_path = self.get_decachunk_folder_path_from_decachunk(decachunky_x, decachunky_z)
if not os.path.isdir(decachunk_folder_path): if not os.path.isdir(decachunk_folder_path):
os.makedirs(decachunk_folder_path) os.makedirs(decachunk_folder_path)
@ -932,24 +958,27 @@ class MTChunks:
def get_chunk_folder_path(self, chunky_x, chunky_z): def get_chunk_folder_path(self, chunky_x, chunky_z):
result = None result = None
decachunky_x = int(math.floor(chunky_x/10)) decachunky_x = self.get_decachunky_coord_from_chunky_coord(chunky_x)
decachunky_z = int(math.floor(chunky_z/10)) decachunky_z = self.get_decachunky_coord_from_chunky_coord(chunky_z)
result = os.path.join( os.path.join(self.data_16px_path, str(decachunky_x)), str(decachunky_z) ) result = os.path.join( os.path.join(self.data_16px_path, str(decachunky_x)), str(decachunky_z) )
return result return result
def get_decachunk_folder_path_from_chunk(self, chunky_x, chunky_z): def get_decachunk_folder_path_from_chunk(self, chunky_x, chunky_z):
result = None result = None
if chunky_x is not None and chunky_z is not None: if chunky_x is not None and chunky_z is not None:
hectochunky_x = int(math.floor(chunky_x/100)) decachunk_x = self.get_decachunky_coord_from_chunky_coord(chunky_x)
hectochunky_x = int(math.floor(chunky_z/100)) decachunk_z = self.get_decachunky_coord_from_chunky_coord(chunky_z)
result = os.path.join( os.path.join(self.data_160px_path, str(hectochunky_x)), str(hectochunky_x) ) #hectochunky_x = int(math.floor(chunky_x/100))
#hectochunky_z = int(math.floor(chunky_z/100))
#result = os.path.join( os.path.join(self.data_160px_path, str(hectochunky_x)), str(hectochunky_x) )
result = self.get_decachunk_folder_path_from_decachunk(decachunk_x, decachunk_z)
return result return result
def get_decachunk_folder_path_from_decachunk(self, decachunky_x, decachunky_z): def get_decachunk_folder_path_from_decachunk(self, decachunky_x, decachunky_z):
result = None result = None
if decachunky_x is not None and decachunky_z is not None: if decachunky_x is not None and decachunky_z is not None:
hectochunky_x = int(math.floor(decachunky_x/10)) hectochunky_x = int(math.floor(float(decachunky_x)/10.0))
hectochunky_x = int(math.floor(decachunky_z/10)) hectochunky_z = int(math.floor(float(decachunky_z)/10.0))
result = os.path.join( os.path.join(self.data_160px_path, str(hectochunky_x)), str(hectochunky_x) ) result = os.path.join( os.path.join(self.data_160px_path, str(hectochunky_x)), str(hectochunky_x) )
return result return result
@ -985,8 +1014,8 @@ class MTChunks:
#if coords is not None: #if coords is not None:
# chunky_x, chunky_z = coords # chunky_x, chunky_z = coords
tmp_path = self.get_chunk_genresults_base_path() tmp_path = self.get_chunk_genresults_base_path()
decachunky_x = int(math.floor(chunky_x/10)) decachunky_x = self.get_decachunky_coord_from_chunky_coord(chunky_x)
decachunky_z = int(math.floor(chunky_z/10)) decachunky_z = self.get_decachunky_coord_from_chunky_coord(chunky_z)
tmp_path = os.path.join( os.path.join(tmp_path, str(decachunky_x)), str(decachunky_z) ) tmp_path = os.path.join( os.path.join(tmp_path, str(decachunky_x)), str(decachunky_z) )
return tmp_path return tmp_path
@ -1186,10 +1215,11 @@ class MTChunks:
self.create_chunk_folder(chunky_x, chunky_z) self.create_chunk_folder(chunky_x, chunky_z)
os.rename(tmp_png_path, dest_png_path) os.rename(tmp_png_path, dest_png_path)
print(min_indent+"(moved to '"+dest_png_path+"')") print(min_indent+"(moved to '"+dest_png_path+"')")
self.total_newly_rendered += 1 self.rendered_this_session_count += 1
self.prepare_chunk_meta(chunky_x, chunky_z) # DOES load existing yml if exists self.prepare_chunk_meta(chunky_x, chunky_z) # DOES load existing yml if exists
self.chunks[chunk_luid].is_fresh = True self.chunks[chunk_luid].is_fresh = True
self.chunks[chunk_luid].metadata["is_empty"] = False self.chunks[chunk_luid].metadata["is_empty"] = False
print (min_indent+"{rendered_this_session_count:"+str(self.rendered_this_session_count)+"}")
except: except:
print (min_indent+"Could not finish moving '"+tmp_png_path+"' to '"+dest_png_path+"'") print (min_indent+"Could not finish moving '"+tmp_png_path+"' to '"+dest_png_path+"'")
else: else:
@ -1515,7 +1545,7 @@ class MTChunks:
this_pos = self.todo_positions[self.todo_index] this_pos = self.todo_positions[self.todo_index]
chunky_x, chunky_z = this_pos chunky_x, chunky_z = this_pos
chunk_luid = self.get_chunk_luid(chunky_x, chunky_z) chunk_luid = self.get_chunk_luid(chunky_x, chunky_z)
prev_total_newly_rendered = self.total_newly_rendered prev_rendered_this_session_count = self.rendered_this_session_count
is_present, reason_string = self.check_chunk(chunky_x, chunky_z) is_present, reason_string = self.check_chunk(chunky_x, chunky_z)
if is_present: if is_present:
@ -1533,7 +1563,7 @@ class MTChunks:
prev_len = len(self.todo_positions) prev_len = len(self.todo_positions)
self._check_map_pseudorecursion_branchfrom(chunky_x, chunky_z) self._check_map_pseudorecursion_branchfrom(chunky_x, chunky_z)
#must check_decachunk_containing_chunk AFTER _check_map_pseudorecursion_branchfrom so check_decachunk_containing_chunk can see if there are more to do before rendering superchunk #must check_decachunk_containing_chunk AFTER _check_map_pseudorecursion_branchfrom so check_decachunk_containing_chunk can see if there are more to do before rendering superchunk
if self.total_newly_rendered>prev_total_newly_rendered: if self.rendered_this_session_count>prev_rendered_this_session_count:
self.check_decachunk_containing_chunk(chunky_x, chunky_z) self.check_decachunk_containing_chunk(chunky_x, chunky_z)
if self.verbose_enable: if self.verbose_enable:
print(min_indent+"["+str(self.todo_index)+"] branching from "+str((chunky_x, chunky_z))+" (added "+str(len(self.todo_positions)-prev_len)+")") print(min_indent+"["+str(self.todo_index)+"] branching from "+str((chunky_x, chunky_z))+" (added "+str(len(self.todo_positions)-prev_len)+")")

237
web/chunkymap.php

@ -250,11 +250,11 @@ function echo_map_heading_text() {
// } // }
// else echo "<span style=\"color:red\">(missing world name)</span>"; // else echo "<span style=\"color:red\">(missing world name)</span>";
// } // }
function get_chunk_folder_path($x, $z) { function get_chunk_folder_path_from_chunky_coords($chunky_x, $chunky_z) {
global $chunkymapdata_thisworld_path; global $chunkymapdata_thisworld_path;
//NOTE: floor converts -.5 to -1 (and -1.5 to -2) but .5 to 0 //NOTE: floor converts -.5 to -1 (and -1.5 to -2) but .5 to 0
$decachunk_x = intval(floor($x/10)); $decachunk_x = get_decachunky_coord_from_chunky_coord($chunky_x);
$decachunk_z = intval(floor($z/10)); $decachunk_z = get_decachunky_coord_from_chunky_coord($chunky_z);
//if ($x<0) { $decachunk_x = $x + $x%10; } //if ($x<0) { $decachunk_x = $x + $x%10; }
//else { $decachunk_x = $x - $x%10; } //else { $decachunk_x = $x - $x%10; }
//if ($z<0) { $decachunk_z = $z + $z%10; } //if ($z<0) { $decachunk_z = $z + $z%10; }
@ -263,17 +263,175 @@ function get_chunk_folder_path($x, $z) {
return $result; return $result;
} }
function get_superchunk_folder_path($x, $z) { function get_decachunk_folder_path_from_location($x, $z) {
global $chunkymapdata_thisworld_path; global $chunkymapdata_thisworld_path;
//NOTE: floor converts -.5 to -1 (and -1.5 to -2) but .5 to 0 //NOTE: floor converts -.5 to -1 (and -1.5 to -2) but .5 to 0
$hectochunk_x = intval(floor($x/100)); $chunky_x = get_chunky_coord_from_location($x);
$hectochunk_z = intval(floor($z/100)); $chunky_z = get_chunky_coord_from_location($z);
$decachunky_x = get_decachunky_coord_from_chunky_coord($chunky_x);
$decachunky_z = get_decachunky_coord_from_chunky_coord($chunky_z);
$hectochunk_x = get_hectochunky_coord_from_decachunky_coord($decachunky_x);
$hectochunk_z = get_hectochunky_coord_from_decachunky_coord($decachunky_z);
$result = $chunkymapdata_thisworld_path.'/160px/'.$hectochunk_x.'/'.$hectochunk_z; $result = $chunkymapdata_thisworld_path.'/160px/'.$hectochunk_x.'/'.$hectochunk_z;
return $result; return $result;
} }
function get_decachunk_folder_path_from_decachunk($chunky_x, $chunky_z) {
global $chunkymapdata_thisworld_path;
//NOTE: floor converts -.5 to -1 (and -1.5 to -2) but .5 to 0
$hectochunk_x = get_hectochunky_coord_from_decachunky_coord($chunky_x);
$hectochunk_z = get_hectochunky_coord_from_decachunky_coord($chunky_z);
$result = $chunkymapdata_thisworld_path.'/160px/'.$hectochunk_x.'/'.$hectochunk_z;
return $result;
}
function get_chunky_coord_from_location($location_x) {
$chunk_x = intval($location_x/16);
return $chunk_x;
}
function get_decachunky_coord_from_chunky_coord($chunky_x) {
return intval(floor((float)$chunky_x/10.0));
}
function get_hectochunky_coord_from_decachunky_coord($chunky_x) {
return intval(floor((float)$chunky_x/10.0));
}
function get_decachunky_coord_from_location($location_x) {
$chunk_x = get_chunky_coord_from_location($location_x);
$decachunk_x = get_decachunky_coord_from_chunky_coord($chunk_x);
return $decachunk_x;
}
function get_decachunk_image_name_from_decachunk($x, $z) {
return "decachunk_x"."$x"."z"."$z".".jpg";
}
function echo_chunkymap_canvas() {
global $chunkymap_view_x;
global $chunkymap_view_z;
global $chunkymap_view_zoom_multiplier;
global $chunkymap_view_zoom_max;
global $chunkymap_view_zoom_min;
global $showplayers;
check_world();
global $chunkymapdata_thisworld_path;
global $world_name;
global $chunkymapdata_worlds_path;
$x_opener="decachunk_x";
$z_opener="z";
$dot_and_ext = ".jpg";
if ($chunkymap_view_zoom_multiplier<$chunkymap_view_zoom_min) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_min;
if ($chunkymap_view_zoom_multiplier>$chunkymap_view_zoom_max) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_max;
$decachunks_per_page = 1.0/$chunkymap_view_zoom_multiplier;
$view_w = (($decachunks_per_page*160.0));
$view_h = (($decachunks_per_page*160.0));
$view_left = (($chunkymap_view_x)) - (($view_w/2.0));
$view_right = $view_left + $view_w;
//z is cartesian still:
$view_top = (($chunkymap_view_z)) + (($view_h/2.0));
$view_bottom = $view_top - $view_h;
echo_chunkymap_anchor();
echo_chunkymap_controls();
echo "\r\n";
echo " ".($chunkymap_view_zoom_multiplier*100.0)."%\r\n";//(string)((int)($chunkymap_view_zoom_multiplier*100+.5));
//"chunkymapdata/images/compass-rose.png"
//"chunkymapdata/images/start.png"
$decachunky_min_x = get_decachunky_coord_from_location($view_left);
$decachunky_min_z = get_decachunky_coord_from_location($view_bottom);
$decachunky_max_x = get_decachunky_coord_from_location($view_right);
$decachunky_max_z = get_decachunky_coord_from_location($view_top);
$decachunky_count_x = $decachunky_max_x-$decachunky_min_x+1;
$decachunky_count_z = $decachunky_max_z-$decachunky_min_z+1;
//#region local vars
$generated_yml_path = $chunkymapdata_thisworld_path."/generated.yml";
//#endregion local vars
$decachunky_z=$decachunky_max_z;
//echo "<br/>";
//echo "$decachunky_min_x:$decachunky_max_x,$decachunky_min_z:$decachunky_max_z<br/>";
$td_placeholder_content="<!--widening table--><img src=\"chunkymapdata/images/decachunk-blank.jpg\" style=\"width:100%; -webkit-filter: opacity(40%); filter: opacity(40%); background-color:black\"/>";
$td_placeholder_content_1px="<!--widening table--><img src=\"chunkymapdata/images/decachunk-blank.jpg\" style=\"width:1px; -webkit-filter: opacity(40%); filter: opacity(40%); background-color:black\"/>";
echo '<table id="chunkymap_table" cellspacing="0" cellpadding="0" style="width:100%">'."\r\n";
echo ' <tr>'."\r\n";
echo ' <td style="width:5%">'."$td_placeholder_content".'</td>'."\r\n";
echo " <td style=\"width:90%\"><a href=\"?$world_name=world_name&chunkymap_view_zoom_multiplier=$chunkymap_view_zoom_multiplier&chunkymap_view_x=$chunkymap_view_x&chunkymap_view_z=".($chunkymap_view_z+($view_h/2.0))."#chunkymap_top\">".'<img src="chunkymapdata/images/arrow-wide-up.png" style="width:100%"/>'.'</a></td>'."\r\n";
echo ' <td style="width:5%">'."$td_placeholder_content".'</td>'."\r\n";
echo ' </tr>'."\r\n";
$cell_perc=intval(round(100.0/$decachunky_count_x));
echo ' <tr>'."\r\n";
echo " <td style=\"width:5%\"><a href=\"?$world_name=world_name&chunkymap_view_zoom_multiplier=$chunkymap_view_zoom_multiplier&chunkymap_view_x=".($chunkymap_view_x-($view_w/2.0))."&chunkymap_view_z=$chunkymap_view_z#chunkymap_top\">".'<img src="chunkymapdata/images/arrow-wide-left.png" style="width:100%"/>'.'</a></td>'."\r\n";
echo ' <td style="width:90%">'."\r\n";
echo ' <table id="decachunk_table" cellspacing="0" cellpadding="0" style="width:100%; background-color:black">'."\r\n";
while ($decachunky_z>=$decachunky_min_z) {
echo ' <tr>'."\r\n";
$decachunky_x=$decachunky_min_x;
$cell_perc_remaining=100;
while ($decachunky_x<=$decachunky_max_x) {
$decachunk_file_name=get_decachunk_image_name_from_decachunk($decachunky_x, $decachunky_z);
$decachunk_file_path=get_decachunk_folder_path_from_decachunk($decachunky_x, $decachunky_z).'/'.$decachunk_file_name;
$td_content="<!--no decachunk $decachunk_file_path--><img src=\"chunkymapdata/images/decachunk-blank.jpg\" style=\"width:100%\"/>";
if (is_file($decachunk_file_path)) {
$td_content="<img src=\"$decachunk_file_path\" style=\"width:100%\"/>";
}
$this_cell_perc=$cell_perc;
if ($cell_perc_remaining>=$this_cell_perc) {
echo " <td style=\"width:$this_cell_perc%\">"."$td_content".'</td>'."\r\n";
//echo ' <td>'."$decachunky_x,$decachunky_z".'</td>'."\r\n";
$cell_perc_remaining-=$this_cell_perc;
}
$decachunky_x+=1;
}
if ($cell_perc_remaining>0) {
$td_content=$td_placeholder_content_1px;
echo " <td>$td_content</td>"."\r\n";
}
echo ' </tr>'."\r\n";
$decachunky_z-=1;
}
echo ' </table>'."\r\n";
echo ' </td>'."\r\n";
echo " <td style=\"width:5%\"><a href=\"?$world_name=world_name&chunkymap_view_zoom_multiplier=$chunkymap_view_zoom_multiplier&chunkymap_view_x=".($chunkymap_view_x+($view_w/2.0))."&chunkymap_view_z=$chunkymap_view_z#chunkymap_top\">".'<img src="chunkymapdata/images/arrow-wide-right.png" style="width:100%"/>'.'</a></td>'."\r\n";
echo ' </tr>'."\r\n";
echo ' <tr>'."\r\n";
echo ' <td style="width:5%">'."$td_placeholder_content".'</td>'."\r\n";
echo " <td style=\"width:90%\"><a href=\"?$world_name=world_name&chunkymap_view_zoom_multiplier=$chunkymap_view_zoom_multiplier&chunkymap_view_x=$chunkymap_view_x&chunkymap_view_z=".($chunkymap_view_z-($view_h/2.0))."#chunkymap_top\">".'<img src="chunkymapdata/images/arrow-wide-down.png" style="width:100%"/>'.'</a></td>'."\r\n";
echo ' <td style="width:5%">'."$td_placeholder_content".'</td>'."\r\n";
echo ' </tr>'."\r\n";
echo '</table>'."\r\n";
}
function check_world() {
global $chunkymapdata_thisworld_path;
global $world_name;
global $chunkymapdata_worlds_path;
if (!isset($world_name)) {
if ($handle = opendir($chunkymapdata_worlds_path)) {
while (false !== ($file_name = readdir($handle))) {
if (substr($file_name, 0, 1) != ".") {
$file_path = $chunkymapdata_worlds_path."/".$file_name;
if (is_dir($file_path)) {
$world_name=$file_name;
break;
}
}
}
closedir($handle);
}
}
if (isset($world_name)) {
$chunkymapdata_thisworld_path = $chunkymapdata_worlds_path."/".$world_name;
}
}
//formerly echo_chunkymap_table //formerly echo_chunkymap_table
function echo_entire_chunkymap_as_chunk_table() { function echo_chunkymap_as_chunk_table($show_all_enable) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); ini_set('display_startup_errors', 1);
error_reporting(E_ALL); error_reporting(E_ALL);
@ -303,7 +461,7 @@ function echo_entire_chunkymap_as_chunk_table() {
if ($chunkymap_view_zoom_multiplier<$chunkymap_view_zoom_min) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_min; if ($chunkymap_view_zoom_multiplier<$chunkymap_view_zoom_min) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_min;
if ($chunkymap_view_zoom_multiplier>$chunkymap_view_zoom_max) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_max; if ($chunkymap_view_zoom_multiplier>$chunkymap_view_zoom_max) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_max;
//$zoom_divisor = (int)(100/$chunkymap_view_zoom_multiplier); //$zoom_divisor = (int)(100/$chunkymap_view_zoom_multiplier);
$chunk_assoc = array(); // used for determining which chunks are on the edge, since not all generated map tiles are the same size (edge tile images are smaller and corner ones are smaller yet) $chunk_assoc = array(); // used for storing players; and used for determining which chunks are on the edge, since not all generated map tiles are the same size (edge tile images are smaller and corner ones are smaller yet)
$chunk_count = 0; $chunk_count = 0;
$x_opener="chunk_x"; $x_opener="chunk_x";
$z_opener="z"; $z_opener="z";
@ -312,29 +470,30 @@ function echo_entire_chunkymap_as_chunk_table() {
$chunkz_min = 0; $chunkz_min = 0;
$chunkx_max = 0; $chunkx_max = 0;
$chunkz_max = 0; $chunkz_max = 0;
$chunks_per_page = (1.0/$chunkymap_view_zoom_multiplier)*10;
$view_w = (($chunks_per_page*16.0));
$view_h = (($chunks_per_page*16.0));
$view_left = (($chunkymap_view_x)) - (($view_w/2.0));
$view_right = $view_left + $view_w;
//z is cartesian still:
$view_top = (($chunkymap_view_z)) + (($view_h/2.0));
$view_bottom = $view_top - $view_h;
if (!$show_all_enable) {
$chunkx_min=intval($view_left/$chunkymap_tile_original_w);
$chunkx_max=intval($view_right/$chunkymap_tile_original_w);
$chunkz_min=intval($view_bottom/$chunkymap_tile_original_w);
$chunkz_max=intval($view_top/$chunkymap_tile_original_w);
}
global $showplayers; global $showplayers;
$players = array(); $players = array();
$player_count = 0; $player_count = 0;
$character_icon_w=8; $character_icon_w=8;
$character_icon_h=8; $character_icon_h=8;
global $chunkymapdata_thisworld_path; global $chunkymapdata_thisworld_path;
if (!isset($world_name)) { check_world();
if ($handle = opendir($chunkymapdata_worlds_path)) {
while (false !== ($file_name = readdir($handle))) {
if (substr($file_name, 0, 1) != ".") {
$file_path = $chunkymapdata_worlds_path."/".$file_name;
if (is_dir($file_path)) {
$world_name=$file_name;
break;
}
}
}
closedir($handle);
}
}
if (isset($world_name)) { if (isset($world_name)) {
$chunkymapdata_thisworld_path = $chunkymapdata_worlds_path."/".$world_name;
$generated_yml_path = $chunkymapdata_thisworld_path."/generated.yml"; $generated_yml_path = $chunkymapdata_thisworld_path."/generated.yml";
if (is_file($generated_yml_path)) { if (is_file($generated_yml_path)) {
$map_dict = get_dict_from_conf($generated_yml_path,":"); $map_dict = get_dict_from_conf($generated_yml_path,":");
@ -508,17 +667,19 @@ function echo_entire_chunkymap_as_chunk_table() {
} }
$chunk_assoc[$chunk_luid]["is_rendered"] = true; $chunk_assoc[$chunk_luid]["is_rendered"] = true;
if ($is_verbose) echo "$chunk_luid,"; if ($is_verbose) echo "$chunk_luid,";
if ($x<$chunkx_min) { if ($show_all_enable) {
$chunkx_min=(int)$x; if ($x<$chunkx_min) {
} $chunkx_min=(int)$x;
if ($x>$chunkx_max) { }
$chunkx_max=(int)$x; if ($x>$chunkx_max) {
} $chunkx_max=(int)$x;
if ($z<$chunkz_min) { }
$chunkz_min=(int)$z; if ($z<$chunkz_min) {
} $chunkz_min=(int)$z;
if ($z>$chunkz_max) { }
$chunkz_max=(int)$z; if ($z>$chunkz_max) {
$chunkz_max=(int)$z;
}
} }
} }
else { else {
@ -568,7 +729,7 @@ function echo_entire_chunkymap_as_chunk_table() {
$chunk_yaml_name = $x_opener.$x.$z_opener.$z.$dot_yaml; $chunk_yaml_name = $x_opener.$x.$z_opener.$z.$dot_yaml;
//$chunk_yaml_path = $chunkymapdata_thisworld_path.'/'.$chunk_yaml_name; //$chunk_yaml_path = $chunkymapdata_thisworld_path.'/'.$chunk_yaml_name;
//$chunk_yaml_path = $chunks_16px_path.'/'. //$chunk_yaml_path = $chunks_16px_path.'/'.
$chunk_yaml_path = get_chunk_folder_path($x, $z).'/'.$chunk_yaml_name; $chunk_yaml_path = get_chunk_folder_path_from_chunky_coords($x, $z).'/'.$chunk_yaml_name;
//$chunk_genresult_name = $x_opener.$x.$z_opener.$z.$genresult_suffix_then_dot_then_ext; //$chunk_genresult_name = $x_opener.$x.$z_opener.$z.$genresult_suffix_then_dot_then_ext;
//$chunk_genresult_path = $chunkymapdata_thisworld_path.'/'.$chunk_img_name; //$chunk_genresult_path = $chunkymapdata_thisworld_path.'/'.$chunk_img_name;
$td_style_suffix=""; $td_style_suffix="";
@ -664,7 +825,7 @@ function echo_entire_chunkymap_as_chunk_table() {
echo_hold("<div style=\"position: relative\">"); //causes child's absolute position to be relative to this div's location, as per http://www.w3schools.com/css/tryit.asp?filename=trycss_position_absolute echo_hold("<div style=\"position: relative\">"); //causes child's absolute position to be relative to this div's location, as per http://www.w3schools.com/css/tryit.asp?filename=trycss_position_absolute
$chunk_luid = "x".$x."z".$z; $chunk_luid = "x".$x."z".$z;
$chunk_img_name = $x_opener.$x.$z_opener.$z."$dot_and_ext"; $chunk_img_name = $x_opener.$x.$z_opener.$z."$dot_and_ext";
$chunk_img_path = get_chunk_folder_path($x, $z).'/'.$chunk_img_name; $chunk_img_path = get_chunk_folder_path_from_chunky_coords($x, $z).'/'.$chunk_img_name;
if (is_file($chunk_img_path)) { if (is_file($chunk_img_path)) {
echo_hold( "<img class=\"maptileimg\" style=\"width:$this_zoomed_w; height:$this_zoomed_h;\" src=\"$chunk_img_path\"/>"); echo_hold( "<img class=\"maptileimg\" style=\"width:$this_zoomed_w; height:$this_zoomed_h;\" src=\"$chunk_img_path\"/>");
} }
@ -761,7 +922,7 @@ function echo_entire_chunkymap_as_chunk_table() {
$img_style.="opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below $img_style.="opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below
$text_style="color:white; opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below $text_style="color:white; opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below
} }
echo_hold( "<div style=\"position:absolute; z-index:999; left:$rel_x; top:$rel_z; width: $zoomed_head_w; height: $zoomed_head_h; $img_border_style\"><img src=\"$image_path\" style=\"$img_style\"/><span style=\"$text_style\">$text</span></div>" ); echo_hold( "<div style=\"position:absolute; z-index:999; left:$rel_x; top:$rel_z; width: $zoomed_image_w; height: $zoomed_image_h; $img_border_style\"><img src=\"$image_path\" style=\"$img_style\"/><span style=\"$text_style\">$text</span></div>" );
} }
//$position_offset_x+=$character_icon_w; //$position_offset_x+=$character_icon_w;
} }

BIN
web/chunkymapdata_default/images/arrow-wide-down.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 908 B

After

Width:  |  Height:  |  Size: 954 B

BIN
web/chunkymapdata_default/images/arrow-wide-left.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 904 B

After

Width:  |  Height:  |  Size: 933 B

BIN
web/chunkymapdata_default/images/arrow-wide-right.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 B

After

Width:  |  Height:  |  Size: 910 B

BIN
web/chunkymapdata_default/images/arrow-wide-up.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 890 B

After

Width:  |  Height:  |  Size: 941 B

BIN
web/chunkymapdata_default/images/chunk-blank-fancy.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

BIN
web/chunkymapdata_default/images/chunk-blank.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

BIN
web/chunkymapdata_default/images/decachunk-blank-fancy.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
web/chunkymapdata_default/images/decachunk-blank.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

7
web/example.php

@ -12,7 +12,7 @@ error_reporting(E_ALL);
if (is_file('chunkymap.php')) { if (is_file('chunkymap.php')) {
//echo "including..."; //echo "including...";
include_once('chunkymap.php'); include_once('chunkymap.php');
//echo "about to call echo_entire_chunkymap_as_chunk_table..."; //echo "about to call echo_chunkymap_as_chunk_table...";
//The following is not needed, since chunkymap.php should be included above and puts all $_REQUEST array variables into $GLOBALS array //The following is not needed, since chunkymap.php should be included above and puts all $_REQUEST array variables into $GLOBALS array
//if (!isset($_REQUEST['chunkymap_view_x'])) {//if (!isset($chunkymap_view_x)) { //if (!isset($_REQUEST['chunkymap_view_x'])) {//if (!isset($chunkymap_view_x)) {
@ -26,9 +26,10 @@ if (is_file('chunkymap.php')) {
echo "</center>"; echo "</center>";
set_chunkymap_view($chunkymap_view_x,$chunkymap_view_z,$chunkymap_view_zoom_multiplier); set_chunkymap_view($chunkymap_view_x,$chunkymap_view_z,$chunkymap_view_zoom_multiplier);
echo "<table><tr><td style=\"text-align:left\">"; echo "<table><tr><td style=\"text-align:left\">";
echo_entire_chunkymap_as_chunk_table(); echo_chunkymap_as_chunk_table(false);
echo_chunkymap_canvas();
echo "</td></tr></table>"; echo "</td></tr></table>";
//echo "returned from echo_entire_chunkymap_as_chunk_table."; //echo "returned from echo_chunkymap_as_chunk_table.";
} }
else { else {
echo "missing chunkymap.php"; echo "missing chunkymap.php";

12
web/update wamp www.bat

@ -0,0 +1,12 @@
SET SRC_MT_WEB_PATH=%USERPROFILE%\Documents\GitHub\minetest-chunkymap\web
SET DEST_MT_WEBSITE_PATH=C:\wamp\www
copy /y "%SRC_MT_WEB_PATH%\browser.php" "%DEST_MT_WEBSITE_PATH%\"
copy /y "%SRC_MT_WEB_PATH%\chunkymap.php" "%DEST_MT_WEBSITE_PATH%\"
copy /y "%SRC_MT_WEB_PATH%\example.php" "%DEST_MT_WEBSITE_PATH%\"
SET DEST_MT_WEBSITE_CHUNKYMAP_IMAGES_PATH=%DEST_MT_WEBSITE_PATH%\chunkymapdata\images
copy /y "%SRC_MT_WEB_PATH%\chunkymapdata_default\images\*" "%DEST_MT_WEBSITE_CHUNKYMAP_IMAGES_PATH%"
if NOT ["%errorlevel%"]==["0"] pause
Loading…
Cancel
Save