Mercurial > hg > batmud > maputils
changeset 2272:0556b65f137b
Cleanups in the web code, show location type again in some places.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 21 Mar 2020 10:24:57 +0200 |
parents | fa98b657c107 |
children | 00ed8ddbe91a |
files | www/common.inc.php www/latest.php www/level.php www/loc.php www/quests.php www/simple.css www/simple.php www/ss.php |
diffstat | 8 files changed, 78 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/www/common.inc.php Fri Mar 20 07:16:27 2020 +0200 +++ b/www/common.inc.php Sat Mar 21 10:24:57 2020 +0200 @@ -42,29 +42,70 @@ // Location types table -define("LTI_NAME_PREFIX" , 0); -define("LTI_PAGE_DESC" , 1); -define("LTI_MENU_TITLE" , 2); -define("LTI_INVERT_FLAGS" , 3); -define("LTI_FLAGS" , 4); +define("LTI_PAGE_DESC" , 0); +define("LTI_MENU_TITLE" , 1); +define("LTI_INVERT_FLAGS" , 2); +define("LTI_FLAGS" , 3); $locationTypes = [ -//ID => Loc name prefix, Page description , Menu title , InvFlags, Mask flags - "" => ["" , "ALL" , "EVERYTHING" , TRUE , 0 ], - "A" => ["" , "Areas" , "Areas" , TRUE , LOCF_MASK ], - "S" => ["SHRINE" , "Race and other shrines" , "Shrines" , FALSE , LOCF_T_SHRINE ], - "G" => ["GUILD" , "Guilds" , "Guilds" , FALSE , LOCF_T_GUILD ], - "P" => ["SS" , "Outworld secret societies" , "SS" , FALSE , LOCF_T_SS ], - "M" => ["MONSTER" , "Special outworld monsters" , "Monsters" , FALSE , LOCF_T_MONSTER ], - "c" => ["CITY" , "Major cities" , "Cities" , FALSE , LOCF_M_CITY ], - "T" => ["TRAINER" , "Guild trainers" , "Trainers" , FALSE , LOCF_T_TRAINER ], - "C" => ["PCITY" , "Player cities" , "PCities" , FALSE , LOCF_M_PCITY ], -//"F" => ["FORT" , "Regional Forts" , "Forts" , FALSE , LOCF_T_FORT ], +//ID => Page description , Menu title , InvFlags, Mask flags + "" => ["ALL" , "EVERYTHING" , TRUE , 0 ], + "A" => ["Areas" , "Areas" , TRUE , LOCF_MASK ], + "S" => ["Race and other shrines" , "Shrines" , FALSE , LOCF_T_SHRINE ], + "G" => ["Guilds" , "Guilds" , FALSE , LOCF_T_GUILD ], + "P" => ["Outworld secret societies" , "SS" , FALSE , LOCF_T_SS ], + "M" => ["Special outworld monsters" , "Monsters" , FALSE , LOCF_T_MONSTER ], + "c" => ["Major cities" , "Cities" , FALSE , LOCF_M_CITY ], + "T" => ["Guild trainers" , "Trainers" , FALSE , LOCF_T_TRAINER ], + "C" => ["Player cities" , "PCities" , FALSE , LOCF_M_PCITY ], +//"F" => ["Regional Forts" , "Forts" , FALSE , LOCF_T_FORT ], ]; +function mpGetLocationTypePrefix($flags) +{ + switch ($flags & LOCF_M_MASK) + { + case LOCF_M_PCITY: return "PCITY "; + case LOCF_M_CITY: return "CITY "; + default: + switch ($flags & LOCF_T_MASK) + { + case LOCF_T_SHRINE: return "SHRINE "; + case LOCF_T_GUILD: return "GUILD "; + case LOCF_T_SS: return "SS "; + case LOCF_T_MONSTER: return "MONSTER "; + case LOCF_T_TRAINER: return "TRAINER "; + case LOCF_T_FORT: return "FORT "; + default: return ""; + } + } +} + + +function mpGetLocationTypeStr($flags) +{ + switch ($flags & LOCF_M_MASK) + { + case LOCF_M_PCITY: return "Player City"; + case LOCF_M_CITY: return "Major City"; + default: + switch ($flags & LOCF_T_MASK) + { + case LOCF_T_SHRINE: return "Race Shrine"; + case LOCF_T_GUILD: return "Guild"; + case LOCF_T_SS: return "SS"; + case LOCF_T_MONSTER: return "Monster"; + case LOCF_T_TRAINER: return "Trainer"; + case LOCF_T_FORT: return "Fort"; + default: return "Area"; + } + } +} + + function mpError($msg) { global $errorSet, $errorMsgs; @@ -173,7 +214,7 @@ } -function mpGetMapURLLink($data, $link, $name, $gmap = TRUE) +function mpGetMapURLLink($data, $link, $name, $gmap) { global $pageGMapURL, $continentList; if ($link) @@ -193,9 +234,10 @@ } -function mpGetMapLink($data, $link, $gmap = TRUE) +function mpGetMapLink($data, $link, $gmap, $ltype) { - return mpGetMapURLLink($data, $link, $data["name"], $gmap); + return mpGetMapURLLink($data, $link, + ($ltype ? mpGetLocationTypePrefix($data["flags"]) : "").$data["name"], $gmap); } @@ -349,7 +391,7 @@ // Add location to array of locations $locations[$id] = [ - "name" => $name, + "name" => $name, // NOTE! Name field should be the first one in this list due to how we are abusing asort() etc "names" => $names, "continent" => $filename, "x" => $record[1],
--- a/www/latest.php Fri Mar 20 07:16:27 2020 +0200 +++ b/www/latest.php Sat Mar 21 10:24:57 2020 +0200 @@ -23,27 +23,6 @@ </div> <hr /> <? -function locGetTypeStr($flags) -{ - switch ($flags & LOCF_M_MASK) - { - case LOCF_M_PCITY: return "Player City"; - case LOCF_M_CITY: return "Major City"; - default: - switch ($flags & LOCF_T_MASK) - { - case LOCF_T_SHRINE: return "Race Shrine"; - case LOCF_T_GUILD: return "Guild"; - case LOCF_T_SS: return "SS"; - case LOCF_T_MONSTER: return "Monster"; - case LOCF_T_TRAINER: return "Trainer"; - case LOCF_T_FORT: return "Fort"; - default: return "Area"; - } - } -} - - $locGetNameLink = function($sdata) { return "<a href=\"loc.php?a=". @@ -118,9 +97,9 @@ echo " <tr>\n". " <td>".(($iv["added"] <= 0) ? "?" : mpStrFTime($iv["added"]))."</td>\n". - " <td class=\"".$iv["continent"]."\">".mpGetMapLink($iv, TRUE)."</td>\n". + " <td class=\"".$iv["continent"]."\">".mpGetMapLink($iv, TRUE, TRUE, FALSE)."</td>\n". " <td>".$continentList[$iv["continent"]][CTI_NAME]."</td>\n". - ($showAll ? " <td>".locGetTypeStr($iv["flags"])."</td>\n" : ""). + ($showAll ? " <td>".mpGetLocationTypeStr($iv["flags"])."</td>\n" : ""). " <td>".implode(", ", array_map( (($iv["flags"] & LOCF_M_MASK) == LOCF_M_PCITY) ? $locGetNameStr : $locGetNameLink, $iv["coders"]))."</td>\n".
--- a/www/level.php Fri Mar 20 07:16:27 2020 +0200 +++ b/www/level.php Sat Mar 21 10:24:57 2020 +0200 @@ -59,7 +59,7 @@ echo " <tr>\n". " <td>". - mpGetMapLink($loc, !isset($continentList[$loc["continent"]]) || $continentList[$loc["continent"]][CTI_HAS_MAP]). + mpGetMapLink($loc, !isset($continentList[$loc["continent"]]) || $continentList[$loc["continent"]][CTI_HAS_MAP], TRUE, FALSE). "</td>\n". " <td>".($data["limit"] > 0 ? $data["limit"] : "?")."</td>\n". ($hcbat ? "" : " <td class=\"".$loc["continent"]."\">".$continentList[$loc["continent"]][CTI_NAME]."</td>").
--- a/www/loc.php Fri Mar 20 07:16:27 2020 +0200 +++ b/www/loc.php Sat Mar 21 10:24:57 2020 +0200 @@ -311,7 +311,7 @@ if (count($alphaLocs) <= 0) continue; $letter = strtoupper($alpha); - asort($alphaLocs); + asort($alphaLocs, SORT_STRING); echo "<h3 class=\"alpha\"><a id=\"ch".$letter."\"></a>".$letter."</h3>\n". @@ -327,7 +327,9 @@ echo " <div class=\"locCell ".$iv["continent"]."\">". "<div class=\"locHeader\">". - "<span class=\"locTitle\">".mpGetMapLink($iv, $continentList[$iv["continent"]][CTI_HAS_MAP])."</span>"; + "<span class=\"locTitle\">". + mpGetMapLink($iv, $continentList[$iv["continent"]][CTI_HAS_MAP], TRUE, TRUE). + "</span>"; // If either freeform desc or URL field are set, we add those if (isset($iv["url"]) || isset($iv["freeform"]))
--- a/www/quests.php Fri Mar 20 07:16:27 2020 +0200 +++ b/www/quests.php Sat Mar 21 10:24:57 2020 +0200 @@ -21,7 +21,7 @@ echo "<td><a href=\"".$batQuestURL.urlencode($name)."\">".chentities($name)."</a></td>". "<td class=\"".$area["continent"]."\">". - mpGetMapLink($area, !isset($continentList[$area["continent"]]) || $continentList[$area["continent"]][CTI_HAS_MAP]). + mpGetMapLink($area, !isset($continentList[$area["continent"]]) || $continentList[$area["continent"]][CTI_HAS_MAP], TRUE, FALSE). "</td>". ($hcbat ? "" : "<td><a href=\"loc.php?n=".$area["continent"]."\">".$continentList[$area["continent"]][CTI_NAME]."</a></td>"); }
--- a/www/simple.css Fri Mar 20 07:16:27 2020 +0200 +++ b/www/simple.css Sat Mar 21 10:24:57 2020 +0200 @@ -24,6 +24,10 @@ padding: 0.2em; } +table.loc td.type { + width: 5%; +} + table.loc td.name { width: 15%; }
--- a/www/simple.php Fri Mar 20 07:16:27 2020 +0200 +++ b/www/simple.php Sat Mar 21 10:24:57 2020 +0200 @@ -58,7 +58,8 @@ // Print location entry echo " <tr>\n". - " <td class=\"name\">".mpGetMapLink($iv, $continentList[$iv["continent"]][CTI_HAS_MAP], FALSE)."</td>\n". + " <td class=\"type\">".mpGetLocationTypeStr($iv["flags"])."</td>\n". + " <td class=\"name\">".mpGetMapLink($iv, $continentList[$iv["continent"]][CTI_HAS_MAP], FALSE, FALSE)."</td>\n". " <td class=\"continent ".$iv["continent"]."\">".$iv["continent"]."</td>\n". " <td class=\"coords\">".$iv["x"].", ".$iv["y"]."</td>\n";
--- a/www/ss.php Fri Mar 20 07:16:27 2020 +0200 +++ b/www/ss.php Sat Mar 21 10:24:57 2020 +0200 @@ -48,8 +48,8 @@ $link = $continentList[$cont][CTI_HAS_MAP]; echo " <tr>\n". - " <td>".mpGetMapURLLink($data, $link, $name)."</td>\n". - " <td class=\"".$cont."\">".mpGetMapLink($data, $link)."</td>\n". + " <td>".mpGetMapURLLink($data, $link, $name, TRUE)."</td>\n". + " <td class=\"".$cont."\">".mpGetMapLink($data, $link, TRUE, FALSE)."</td>\n". " <td>".chentities($continentList[$cont][CTI_NAME])."</td>\n". " </tr>\n"; }