Browse Source

added marker system

master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
ce86b29f97
  1. BIN
      etc/arrow-wide.xcf
  2. 5
      update-chunkymap-on-ubuntu-from-web.sh
  3. 122
      web/chunkymap.php
  4. BIN
      web/chunkymapdata_default/images/arrow-wide-down.png
  5. BIN
      web/chunkymapdata_default/images/arrow-wide-left.png
  6. BIN
      web/chunkymapdata_default/images/arrow-wide-right.png
  7. BIN
      web/chunkymapdata_default/images/arrow-wide-up.png
  8. 2
      web/chunkymapdata_default/world/markers/0.yml

BIN
etc/arrow-wide.xcf

Binary file not shown.

5
update-chunkymap-on-ubuntu-from-web.sh

@ -24,9 +24,10 @@ MT_MY_WEBSITE_PATH=/var/www/html/minetest
if [ -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" ]; then
if [ -f "$MT_MY_WEBSITE_PATH/chunkymap.php" ]; then
sudo cp -f "$HOME/Downloads/minetest-chunkymap/web/chunkymap.php" "$MT_MY_WEBSITE_PATH/"
sudo cp --no-clobber "$HOME/Downloads/minetest-chunkymap/web/example.php" "$MT_MY_WEBSITE_PATH/viewchunkymap.php"
#sudo cp --no-clobber "$HOME/Downloads/minetest-chunkymap/web/example.php" "$MT_MY_WEBSITE_PATH/viewchunkymap.php"
sudo cp -f "$HOME/Downloads/minetest-chunkymap/web/example.php" "$MT_MY_WEBSITE_PATH/example.php"
# cannot put wildcard in quotes on unix
sudo cp -R --no-clobber $HOME/Downloads/minetest-chunkymap/web/images/* "$MT_MY_WEBSITE_PATH/images/"
#sudo cp -R --no-clobber $HOME/Downloads/minetest-chunkymap/web/images/* "$MT_MY_WEBSITE_PATH/images/"
#--no-clobber: do not overwrite existing
fi
fi

122
web/chunkymap.php

@ -375,10 +375,10 @@ function echo_entire_chunkymap_as_chunk_table() {
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "file_path" ] = $file_path;
if (isset($player_dict["name"])) {
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "name" ] = $player_dict["name"];
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "text" ] = $player_dict["name"];
}
else {
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "name" ] = $player_dict["id"];
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "text" ] = $player_dict["id"];
}
$chunk_assoc[$chunk_luid]["players_count"] += 1;
//}
@ -394,8 +394,65 @@ function echo_entire_chunkymap_as_chunk_table() {
}
}
}
closedir($handle);
}
}
$chunkymap_markers_path = $chunkymapdata_thisworld_path."/markers";
if ($handle = opendir($chunkymap_markers_path)) {
while (false !== ($file_name = readdir($handle))) {
if (substr($file_name, 0, 1) != ".") {
$file_name_lower = strtolower($file_name);
if (endsWith($file_name_lower, ".yml")) {
$file_path = $chunkymap_markers_path."/".$file_name;
$marker_vars = get_dict_from_conf($file_path, ":");
$abs_pos = explode(",",$marker_vars["location"]);
if (count($abs_pos)==3) {
//convert from 3d to 2d:
$abs_pos[1]=$abs_pos[3];
}
//$text = "";
//if (isset($marker_vars["text"])) {
// $text = $marker_vars["text"];
//}
if (count($abs_pos)>=2) {
$chunky_x = intval($abs_pos[0]/$chunkymap_tile_original_w);
$chunky_z = intval($abs_pos[1]/$chunkymap_tile_original_h);
$rel_x = intval($abs_pos[0]) - ($chunky_x*$chunkymap_tile_original_w);
$rel_z = intval($abs_pos[1]) - ($chunky_z*$chunkymap_tile_original_h);
$chunk_luid = 'x'.$chunky_x.'z'.$chunky_z;
if (!isset($chunk_assoc[$chunk_luid])) {
$chunk_assoc[$chunk_luid] = array();
}
if (!isset($chunk_assoc[$chunk_luid]["markers"])) {
$chunk_assoc[$chunk_luid]["markers"] = array();
}
if (!isset($chunk_assoc[$chunk_luid]["markers_count"])) {
$chunk_assoc[$chunk_luid]["markers_count"] = 0;
}
$chunk_assoc[$chunk_luid][ "markers" ][ $chunk_assoc[$chunk_luid]["markers_count"] ][ "x" ] = $abs_pos[0];
$chunk_assoc[$chunk_luid][ "markers" ][ $chunk_assoc[$chunk_luid]["markers_count"] ][ "z" ] = $abs_pos[1];
$chunk_assoc[$chunk_luid][ "markers" ][ $chunk_assoc[$chunk_luid]["markers_count"] ][ "rel_x" ] = $rel_x;
$chunk_assoc[$chunk_luid][ "markers" ][ $chunk_assoc[$chunk_luid]["markers_count"] ][ "rel_z" ] = $rel_z;
if (isset($marker_vars["image"])) {
$chunk_assoc[$chunk_luid][ "markers" ][ $chunk_assoc[$chunk_luid]["markers_count"] ][ "image" ] = $marker_vars["image"];
}
if (isset($marker_vars["text"])) {
$chunk_assoc[$chunk_luid][ "markers" ][ $chunk_assoc[$chunk_luid]["markers_count"] ][ "text" ] = $marker_vars["text"];
}
$chunk_assoc[$chunk_luid]["markers_count"] += 1;
}
else {
echo_error("Bad location in marker file '$file_path'");
}
}
}
}
}
//if ($map_dict != null) {
// $chunkx_min = $map_dict["chunkx_min"];
// $chunkz_min = $map_dict["chunkz_min"];
@ -612,9 +669,9 @@ function echo_entire_chunkymap_as_chunk_table() {
$is_idle=true;
}
}
$player_name = $chunk_assoc[$chunk_luid]["players"][$player_count]["name"];
if (strlen($chunk_assoc[$chunk_luid]["players"][$player_count]["name"])>$nonprivate_name_beginning_char_count) {
$player_name = substr($player_name, 0, $nonprivate_name_beginning_char_count)."*";
$text = $chunk_assoc[$chunk_luid]["players"][$player_count]["text"];
if (strlen($chunk_assoc[$chunk_luid]["players"][$player_count]["text"])>$nonprivate_name_beginning_char_count) {
$text = substr($text, 0, $nonprivate_name_beginning_char_count)."*";
}
//show head full size (not zoomed):
$zoomed_head_w=$character_icon_w;//(int)((float)$character_icon_w*$scale+.5);
@ -631,13 +688,66 @@ function echo_entire_chunkymap_as_chunk_table() {
$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
}
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=\"$chunkymapdata_thisworld_path/players/singleplayer.png\" style=\"$img_style\"/><span style=\"$text_style\">$player_name</span></div>" );
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=\"$chunkymapdata_thisworld_path/players/singleplayer.png\" style=\"$img_style\"/><span style=\"$text_style\">$text</span></div>" );
}
//$position_offset_x+=$character_icon_w;
}
}
else echo "<!--CHUNK $chunk_luid: no player count-->";
if (isset($chunk_assoc[$chunk_luid]["markers_count"])) {
echo "<!--CHUNK $chunk_luid: markers_count=".$chunk_assoc[$chunk_luid]["markers_count"]."-->";
$nonprivate_name_beginning_char_count = 20;
for ($marker_count=0; $marker_count<$chunk_assoc[$chunk_luid]["markers_count"]; $marker_count++) {
$rel_x = $chunk_assoc[$chunk_luid][ "markers" ][ $marker_count ]["rel_x"];
$rel_z = $chunk_assoc[$chunk_luid][ "markers" ][ $marker_count ]["rel_z"];
$is_expired=false;
$is_idle=false;
// if (isset($chunk_assoc[$chunk_luid][ "markers" ][ $marker_count ]["file_path"])) {
// $last_marker_update_time=filemtime($chunk_assoc[$chunk_luid][ "markers" ][ $marker_count ]["file_path"]);
// if (time()-$last_marker_update_time > $marker_file_age_expired_max_seconds) {
// $is_expired=true;
// }
// elseif (time()-$last_marker_update_time > $marker_file_age_idle_max_seconds) {
// $is_idle=true;
// }
// }
$text = $chunk_assoc[$chunk_luid]["markers"][$marker_count]["text"];
$image_path = "";
if (isset($chunk_assoc[$chunk_luid]["markers"][$marker_count]["image"])) {
$image_path = $chunk_assoc[$chunk_luid]["markers"][$marker_count]["image"];
}
if (strlen($chunk_assoc[$chunk_luid]["markers"][$marker_count]["text"])>$nonprivate_name_beginning_char_count) {
$text = substr($text, 0, $nonprivate_name_beginning_char_count)."*";
}
//show head full size (not zoomed):
//$zoomed_head_w=$character_icon_w;//(int)((float)$character_icon_w*$scale+.5);
//$zoomed_head_h=$character_icon_h;//(int)((float)$character_icon_h*$scale+.5);
$zoomed_image_w=16;
$zoomed_image_h=16;
$rel_x -= (int)($zoomed_image_w/2);
$rel_z -= (int)($zoomed_image_h/2);
//$img_style="position:absolute; ";
$img_style="";
$img_border_style="";
//$img_border_style="border: 1px solid white;";
$text_style="color:white;";
if ($is_expired==false) {
if ($is_idle==true) {
$img_border_style="";
//$img_border_style="border: 1px solid rgba(128,128,128,.5);";
$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
}
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>" );
}
//$position_offset_x+=$character_icon_w;
}
}
else echo "<!--CHUNK $chunk_luid: no player count-->";
//echo " <br/>".$x.",0,".$z;
echo_hold($alignment_comment);
echo_hold("</div>");

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

2
web/chunkymapdata_default/world/markers/0.yml

@ -1,4 +1,4 @@
label:start
text:Starting Location
location:0.0,0.0
image:chunkymapdata/images/start.png
comment:formerly chunk_markers_x0z0.yml
Loading…
Cancel
Save