From c5175d4a06c993ff7f42c16178b6d4db49b7387e Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Mon, 18 Mar 2013 01:32:14 -0700 Subject: Wall orientation achievements - huge commit. --- css/page.css | 2 +- globe.php | 6 ++++ images/marks/rotate.php | 5 ++- includes/chats.php | 3 +- includes/constants.php | 2 +- includes/datas.php | 18 ++++++++-- includes/header.php | 9 ++--- index.php | 6 ++-- js/mapspecs.js | 19 +++++++++- js/scores.js | 13 +++---- pages/achievements.php | 94 ++++++++++++++++++++++++++++++++++++------------- pages/chat.php | 2 +- 12 files changed, 133 insertions(+), 46 deletions(-) diff --git a/css/page.css b/css/page.css index 10038e4..d396766 100644 --- a/css/page.css +++ b/css/page.css @@ -299,7 +299,7 @@ position:absolute;color:#333;left:25px;bottom:20px; font-weight:bold; padding: 15px 0px 15px 0px; padding: 0px; - height:50px + height:50px; text-align:center; position: relative; min-width: 960px; diff --git a/globe.php b/globe.php index 7353e74..7a3d472 100644 --- a/globe.php +++ b/globe.php @@ -20,6 +20,12 @@ function LogError($error) { fclose($fd); } +function linkEmblem($emblem, $orientation) { + $orientation = $orientation - 0; + $url = 'images/marks/'; + if ($orientation == 0) return $url.$emblem; + return $url.'rotate.php?r='.$orientation.'&emblem='.$emblem; +} function soundManager1() { return ' diff --git a/images/marks/rotate.php b/images/marks/rotate.php index 9b0a3fe..41a203a 100644 --- a/images/marks/rotate.php +++ b/images/marks/rotate.php @@ -10,7 +10,10 @@ $degrees = $_GET['r'] * 90; // Content type header('Content-type: image/jpeg'); -//TODO Add cache +//TODO Update Cache +header("Cache-Control: private, max-age=10800, pre-check=10800"); +header("Pragma: private"); +header("Expires: " . date(DATE_RFC822,strtotime(" 2 day"))); $simage = @imagecreatefrompng($emblem); if(!$simage) { diff --git a/includes/chats.php b/includes/chats.php index 18d0810..6991a48 100644 --- a/includes/chats.php +++ b/includes/chats.php @@ -62,7 +62,8 @@ function getChat($startID = 0) { users.displayName, users.displayColor, users.wallColor, - users.wallEmblem + users.wallEmblem, + users.wallOrientation FROM `chat` LEFT JOIN `users` ON chat.userID = users.ID diff --git a/includes/constants.php b/includes/constants.php index 7b32819..a1d4dbe 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -84,7 +84,7 @@ $tierChallengeRequirements = array(0, 5, 10, 15, 20, 25, 30); define('UNLOCK_WALL_COLOR', 1); define('UNLOCK_WALL_EMBLEM', 2); define('UNLOCK_DISPLAY_COLOR', 3); -define('UNLOCK_WALL_ROTATION', 4); +define('UNLOCK_WALL_ORIENTATION', 4); define('UNLOCK_EXTRAS', 8); // MISC SUBTYPES: diff --git a/includes/datas.php b/includes/datas.php index f599533..af10cd2 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -110,11 +110,19 @@ function displayUnlock($uType, $uValue, $uName) { case UNLOCK_DISPLAY_COLOR: $r .= "
$uName Username color!"; + break; + + case UNLOCK_WALL_ORIENTATION: + $r .= "Emblem Rotation $uName!"; break; case UNLOCK_EXTRAS: $r .= "Extras: $uName"; break; + + default: + $r .= "$uName"; + break; } return $r; } @@ -684,9 +692,13 @@ function getPerfectDayArray() { //($required, $unlockType, $unlockValue, $unlockName, $unlockSubtype) //$cp[0] = array(requiredpoints, type, 'value', 'name'); $r[1] = array(1, UNLOCK_EXTRAS, '5', 'Insane Speed', MISC_UNLOCK_INSANE_SPEED); + //Give 0* at the same time + $r[2] = array(5, UNLOCK_WALL_ORIENTATION, '1', '90*', 0); + $r[3] = array(50, UNLOCK_WALL_ORIENTATION, '2', '180*', 0); + $r[4] = array(100, UNLOCK_WALL_ORIENTATION, '3', '270*', 0); //These numbers temporarly unreasonable - $r[2] = array(9275, UNLOCK_WALL_EMBLEM, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0); - $r[3] = array(10000, UNLOCK_WALL_EMBLEM, 'DiamondLarge_W_I.png', 'Inverted Light Large Diamond', 0); + $r[5] = array(9275, UNLOCK_WALL_EMBLEM, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0); + $r[6] = array(10000, UNLOCK_WALL_EMBLEM, 'DiamondLarge_W_I.png', 'Inverted Light Large Diamond', 0); return $r; } @@ -748,6 +760,7 @@ function getMembers($pageNumber = 1, $pageDivide = 50, $order = 'DESC', $orderBy users.wallColor, users.displayColor, users.wallEmblem, + users.wallOrientation, users.datejoined as dateJoined, users.dateLogin as dateLogin FROM `users` @@ -844,6 +857,7 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { users.displayColor, users.wallColor, users.wallEmblem, + users.wallOrientation, $requestSolutions solutions.dateModified as cdate, solutions.ID as solutionID diff --git a/includes/header.php b/includes/header.php index 3965357..71c2a5c 100644 --- a/includes/header.php +++ b/includes/header.php @@ -153,7 +153,7 @@ function htmlFooter() { } function topbar($links) { - global $accepted, $wallColor, $wallEmblem, $request; + global $accepted, $wallColor, $wallEmblem, $wallOrientation, $request; @@ -191,7 +191,7 @@ function topbar($links) { echo " Update your name | "; echo " Logout"; echo " "; - echo "
+ echo "
"; @@ -207,9 +207,9 @@ function topbar($links) { } function userDataToJS() { - global $wallColor, $wallEmblem, $accepted; + global $wallColor, $wallEmblem, $wallOrientation, $accepted; if (!$accepted) { - $r = 'var userObj = {"wallColor":false,"wallEmblem":false,'; + $r = 'var userObj = {"wallColor":false,"wallEmblem":false,"wallOrientation":false,'; $r .= '"ID":"-1","accepted":false,"hasInsaneSpeed":false};'; } else { $userID = $_SESSION['userID']; @@ -220,6 +220,7 @@ function userDataToJS() { $json['ID'] = $userID; $json['wallColor'] = $wallColor; $json['wallEmblem'] = $wallEmblem; + $json['wallOrientation'] = $wallOrientation; $json['hasInsaneSpeed'] = $hasInsaneSpeed; $json['accepted'] = 'true'; diff --git a/index.php b/index.php index 2786237..ed7a836 100644 --- a/index.php +++ b/index.php @@ -31,12 +31,12 @@ if ($accepted) { $sql = " SELECT users.wallColor, - users.wallEmblem + users.wallEmblem, + users.wallOrientation FROM `users` WHERE ID = '$userID' "; $result = mysql_query($sql); - if ($result) - list($wallColor, $wallEmblem) = mysql_fetch_row($result); + if ($result) list($wallColor, $wallEmblem, $wallOrientation) = mysql_fetch_row($result); } // Footer Links diff --git a/js/mapspecs.js b/js/mapspecs.js index 5a124b1..cf2450a 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -21,6 +21,7 @@ else if (document.attachEvent) { // IE 8- var wallColor = false; var wallEmblem = false; +var wallOrientation = 0; var isChallenge = false; var isTutorial = false; @@ -84,6 +85,13 @@ function changeWallEmblem(newEmblem) { loadSol(null); } +function linkEmblem(emblem, orientation) { + orientation = orientation - 0; + var url = 'images/marks/'; + if (orientation == 0) return url+emblem; + return url+'rotate.php?r='+orientation+'&emblem='+emblem; +} + function grid_click(obj) { //Prepare data @@ -141,9 +149,18 @@ function grid_click(obj) { wallEmblem = playerWallEmblem; } } + //TODO: Copy below - above w/ userObj + if (wallOrientation == false) { + if (typeof userObj !== 'undefined' && userObj.wallOrientation !== '') { + wallOrientation = userObj.wallOrientation; + } + } + obj.style.backgroundColor = wallColor; if (wallEmblem !== false) { - obj.style.backgroundImage="url(images/marks/"+wallEmblem+")"; + //obj.style.backgroundImage="url(images/marks/"+wallEmblem+")"; + //obj.style.backgroundImage="url(images/marks/rotate.php?r=1&emblem="+wallEmblem+")"; + obj.style.backgroundImage="url("+linkEmblem(wallEmblem, wallOrientation)+")"; } //Add Wall diff --git a/js/scores.js b/js/scores.js index 0e81213..3e01ca8 100644 --- a/js/scores.js +++ b/js/scores.js @@ -188,7 +188,7 @@ function scoresFormatPage(JO) { } p = p+ i+ ""; p = p+ ""; - p = p+ "
"; + p = p+ "
"; p = p+ "
"; p = p+ "
"; p = p+ "
"; @@ -443,19 +443,20 @@ function membersFormatPage(JO) { var styleClass = ''; - if (previousI != i + 1) - if (previousI < i - 1 && previousI != 0) + if (previousI != i + 1) { + if (previousI < i - 1 && previousI != 0) { styleClass = 'border-top: 6px solid #777799;'; + } + } - if (u.wallEmblem == undefined) - u.wallEmblem = 'blank.png'; + if (u.wallEmblem == undefined) u.wallEmblem = 'blank.png'; p = p+ ""; p = p+ ""; p = p+ i+ ""; p = p+ ""; - p = p+ "
"; + p = p+ "
"; p = p+ "
"; p = p+ "
"; p = p+ "
"; diff --git a/pages/achievements.php b/pages/achievements.php index 383de70..fb20f2b 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -55,8 +55,6 @@ foreach ($ac3 as $c3) { echo ""; foreach ($ac1 as $c1) { foreach ($ac2 as $c2) { - - $c = "#$c1$c2$c3"; if ($_GET['showcolor'] == 'all') { //echo ""; @@ -177,7 +175,8 @@ function emblemclick(obj, emblem, unlockID) { if (viewer) return; var hbadge = document.getElementById('badge'); - hbadge.style.backgroundImage="url(images/marks/"+emblem+")"; + var orientation = document.getElementById('selectOrientation').value; + hbadge.style.backgroundImage="url("+linkEmblem(emblem, orientation)+")" document.getElementById('selectEmblem').value = emblem; document.getElementById('selectEmblemID').value = unlockID; } @@ -190,6 +189,17 @@ function namecolorclick(obj, color, unlockID) { document.getElementById('selectNameColor').value = color; document.getElementById('selectNameColorID').value = unlockID; } +function wallOrientationClick(obj, orientation, unlockID) { + if (viewer) return; + var emblem = document.getElementById('selectEmblem').value; + var hbadge = document.getElementById('badge'); + hbadge.style.backgroundImage="url("+linkEmblem(emblem, orientation)+")"; + +// hbadge.style.backgroundImage="url("+linkEmblem(emblem, +")"; + document.getElementById('selectOrientation').value = orientation; + document.getElementById('selectOrientationID').value = unlockID; +} + 0, 'subtype' => 0, 'name' => 'Default Charcoal', 'value' => '#666666', 'aType' => -1); $unlocks[2][0] = array('id' => 0, 'subtype' => 0, 'name' => 'Default Blank', 'value' => 'blank.png', 'aType' => -1); $unlocks[3][0] = array('id' => 0, 'subtype' => 0, 'name' => 'Default', 'value' => '#cccccc', 'aType' => -1); +$unlocks[4][0] = array('id' => 0, 'subtype' => 0, 'name' => 'Default: (0*)', 'value' => '0', 'aType' => -1); $sql = "SELECT unlocks.id, unlocks.type, @@ -221,6 +232,9 @@ if ($result) { $unlocks[$row['type']][$row['id']] = $row; } +//Destroy some defaults to make them not show up. +if (count($unlocks[3]) == 1) unset($unlocks[3]); +if (count($unlocks[4]) == 1) unset($unlocks[4]); //print_R($_POST); @@ -237,12 +251,14 @@ if (isset($_POST['doupdate']) AND !$viewer) { $unlockIDNC = $_POST['selectNameColorID']; $unlockNameColor = $unlocks[3][$unlockIDNC]['value']; - if ($unlockIDC == 0) - $unlockColor = '#666666'; - if ($unlockIDE == 0) - $unlockEmblem = 'blank.png'; - if ($unlockIDNC == 0) - $unlockNameColor = '#cccccc'; + $orientationUnlockID = $_POST['selectOrientationID']; + $orientationNewValue = $unlocks[UNLOCK_WALL_ORIENTATION][$orientationUnlockID]['value']; + + //Default values + if ($unlockIDC == 0) $unlockColor = '#666666'; + if ($unlockIDE == 0) $unlockEmblem = 'blank.png'; + if ($unlockIDNC == 0) $unlockNameColor = '#cccccc'; + if ($orientationUnlockID == 0) $orientationNewValue = '0'; if ($unlockColor == $_POST['selectColor']) { $sql = "UPDATE `users` @@ -271,7 +287,6 @@ if (isset($_POST['doupdate']) AND !$viewer) { $data['post'] = print_r($_POST, true); EmailError($data); } - } if ($unlockNameColor == $_POST['selectNameColor']) { $sql = "UPDATE `users` @@ -287,6 +302,20 @@ if (isset($_POST['doupdate']) AND !$viewer) { EmailError($data); } } + if ($orientationNewValue == $_POST['selectOrientation']) { + $sql = "UPDATE `users` + SET `wallOrientation` = '$orientationNewValue' + WHERE `ID` = '$userID'"; + $result = mysql_query($sql); + if (!$result) { + echo "Error updating wall Orientation"; + $data = array(); + $data['error'] = "Error when updating wall orientation"; + $data['session'] = print_r($_SESSION, true); + $data['post'] = print_r($_POST, true); + EmailError($data); + } + } } $achievements = array(); @@ -325,7 +354,8 @@ SELECT users.totalMazes AS totalSolutions, users.wallColor, users.displayColor, - users.wallEmblem + users.wallEmblem, + users.wallOrientation FROM `users` LEFT JOIN `solutions` ON users.ID = solutions.userID @@ -341,7 +371,7 @@ if (!$result OR mysql_num_rows($result) <= 0) { htmlFooter(); exit; } -list($UDisplay, $UAdmin, $UTotalMoves, $UTotalSolutions, $wallColor, $nameColor, $wallEmblem) = mysql_fetch_row($result); +list($UDisplay, $UAdmin, $UTotalMoves, $UTotalSolutions, $wallColor, $nameColor, $wallEmblem, $wallOrientation) = mysql_fetch_row($result); if ($wallEmblem == '') $wallEmblem = 'blank.png'; @@ -353,11 +383,12 @@ $uStats[1] = $UTotalMoves; $uStats[2] = $UTotalSolutions; echo "
"; -if ($viewer) - echo "

Viewing

"; +if ($viewer) echo "

Viewing

"; + +$badgeURL = linkEmblem($wallEmblem, $wallOrientation); echo "

-
+
$UDisplay

"; @@ -387,7 +418,7 @@ function unlockItemAsTD($uType, $item) { //return $r; switch ($uType) { - case 1: + case UNLOCK_WALL_COLOR: if ($GLOBALS['wallColor'] == $item[value]) { $class = 'grid_td_active'; $border = 'border: 1px solid #26b;'; @@ -395,7 +426,7 @@ function unlockItemAsTD($uType, $item) { $r .= ""; break; - case 2: + case UNLOCK_WALL_EMBLEM: if ($GLOBALS['wallEmblem'] == $item[value]) { $class = 'grid_td_active'; $border = 'border: 1px solid #26b;'; @@ -404,13 +435,22 @@ function unlockItemAsTD($uType, $item) {
"; break; - case 3: + case UNLOCK_DISPLAY_COLOR: if ($GLOBALS['nameColor'] == $item[value]) $border = 'border: 1px solid #26b;'; $r .= ""; $r .= " $item[name] "; $r .= ""; break; + + case UNLOCK_WALL_ORIENTATION: + $checked = ''; + if (intval($GLOBALS['wallOrientation']) == intval($item[value])) $checked = 'checked'; + //$r .= ""; + $r .= ""; + $r .= "$item[name] "; + $r .= ""; + break; case UNLOCK_EXTRAS: $r .= "$item[name]"; @@ -424,16 +464,17 @@ if (isset($unlocks)) { echo "

Unlocks

"; //Define some names - $uTypeNames[1] = "Wall Colors"; - $uTypeNames[2] = "Emblems"; - $uTypeNames[3] = "Username Colors"; + $uTypeNames[UNLOCK_WALL_COLOR] = "Wall Colors"; + $uTypeNames[UNLOCK_WALL_EMBLEM] = "Emblems"; + $uTypeNames[UNLOCK_DISPLAY_COLOR] = "Username Colors"; + $uTypeNames[UNLOCK_WALL_ORIENTATION] = "Emblem Rotations"; $uTypeNames[UNLOCK_EXTRAS] = "Extras"; - $uSubtypeNames[1][0] = "Darker"; - $uSubtypeNames[1][1] = "Brighter"; + $uSubtypeNames[UNLOCK_WALL_COLOR][0] = "Darker"; + $uSubtypeNames[UNLOCK_WALL_COLOR][1] = "Brighter"; - $uSubtypeNames[2][0] = "Simple"; - $uSubtypeNames[2][1] = "Complicated"; + $uSubtypeNames[UNLOCK_WALL_EMBLEM][0] = "Simple"; + $uSubtypeNames[UNLOCK_WALL_EMBLEM][1] = "Complicated"; //For every unlock type that the user has. foreach ($unlocks as $uType => $unlock) { @@ -463,6 +504,7 @@ echo "
"; if (!$viewer) { + //TODO add wall orientation echo "
@@ -470,6 +512,8 @@ if (!$viewer) { + + diff --git a/pages/chat.php b/pages/chat.php index 5be6689..68a0abf 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -101,7 +101,7 @@ function getChatDone(data) { p = ''; p = p+ "
"; p = p+ " ["+timestamp+"]"; - p = p+ "
"; + p = p+ "
"; p = p+ "
"; p = p+ "
"; p = p+ "
"; -- cgit v1.2.3