diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-03-18 01:32:14 -0700 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-03-18 01:32:14 -0700 |
commit | c5175d4a06c993ff7f42c16178b6d4db49b7387e (patch) | |
tree | d8629d21c81c27fe2cb52b2e201285c3449d1e7c | |
parent | aa2388203ebc2fad01b8280777e5a40de4fcc813 (diff) | |
download | pathery-c5175d4a06c993ff7f42c16178b6d4db49b7387e.tar.xz |
Wall orientation achievements - huge commit.
-rw-r--r-- | css/page.css | 2 | ||||
-rw-r--r-- | globe.php | 6 | ||||
-rw-r--r-- | images/marks/rotate.php | 5 | ||||
-rw-r--r-- | includes/chats.php | 3 | ||||
-rw-r--r-- | includes/constants.php | 2 | ||||
-rw-r--r-- | includes/datas.php | 18 | ||||
-rw-r--r-- | includes/header.php | 9 | ||||
-rw-r--r-- | index.php | 6 | ||||
-rw-r--r-- | js/mapspecs.js | 19 | ||||
-rw-r--r-- | js/scores.js | 13 | ||||
-rw-r--r-- | pages/achievements.php | 94 | ||||
-rw-r--r-- | 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;
@@ -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 .= "<br /><span style='color:$uValue;font-weight:bold;font-size:110%;background-color:#222;'>$uName Username color!</span>"; + 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 " <a href='cp' title='change name'>Update your name</a> | ";
echo " <a href='logout'>Logout</a>";
echo " </div>";
- echo "<div id='topbarBadge' style='background-color: $wallColor; background-image: url(images/marks/$wallEmblem);'>
+ echo "<div id='topbarBadge' style='background-color: $wallColor; background-image: url(".linkEmblem($wallEmblem, $wallOrientation).");'>
<a href='achievements'><div></div></a>
</div>";
@@ -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';
@@ -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+ "</td>";
p = p+ "<td style='vertical-align: middle;'>";
- p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url(images/marks/"+u.wallEmblem+");'>";
+ p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url("+linkEmblem(u.wallEmblem, u.wallOrientation)+");'>";
p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
p = p+ " </div>";
p = p+ " </div>";
@@ -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+ "<tr style='"+styleClass+" background-color: "+u.background+"; color:"+u.displayColor+";' title=''>";
p = p+ "<td style='text-align:left;'>";
p = p+ i+ "</td>";
p = p+ "<td style='vertical-align: middle;width:180px;'>";
- p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url(images/marks/"+u.wallEmblem+");'>";
+ p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url("+linkEmblem(u.wallEmblem, u.wallOrientation)+");'>";
p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
p = p+ " </div>";
p = p+ " </div>";
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 "</tr><tr>";
foreach ($ac1 as $c1) {
foreach ($ac2 as $c2) {
-
-
$c = "#$c1$c2$c3";
if ($_GET['showcolor'] == 'all') {
//echo "<td onclick='changeWallColor(\"#$c1$c2$c3\")' title='#$c1$c2$c3' style='background-color:#$c3$c1$c2;' class='grid_td_rocks'></td>";
@@ -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;
+}
+
</script>
<?
@@ -201,6 +211,7 @@ function namecolorclick(obj, color, unlockID) { $unlocks[1][0] = array('id' => 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 "<div class='wrapper' style='padding-left:30px; width:800px;'>";
-if ($viewer)
- echo "<center><h3>Viewing</h3></center>";
+if ($viewer) echo "<center><h3>Viewing</h3></center>";
+
+$badgeURL = linkEmblem($wallEmblem, $wallOrientation);
echo "
<h1 id='badgeheader' style='margin-left:10px;color:$nameColor;'>
-<div id='badge' style='margin-right:10px; background:$wallColor url(../images/marks/$wallEmblem);float:left;background-size:100%;' class='badge'>
+<div id='badge' style='margin-right:10px; background:$wallColor url($badgeURL);float:left;background-size:100%;' class='badge'>
<div style='width:100%; height:100%; background-color:transparent; background-size:100%;' class='grid_td_rocks grid_inner'></div>
</div>$UDisplay</h1>";
@@ -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 .= "<td class='grid_td $class' id='color_$item[id]' title='$unlockTitle' onClick='colorclick(this,\"$item[value]\", \"$item[id]\")' style='padding: 0px;background-color:$item[value];$border'></td>";
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) { <div class='grid_inner $class grid_td_walls'></div></td>";
break;
- case 3:
+ case UNLOCK_DISPLAY_COLOR:
if ($GLOBALS['nameColor'] == $item[value])
$border = 'border: 1px solid #26b;';
$r .= "<td class='name_color_select'><span title='$unlockTitle' onClick='namecolorclick(this,\"$item[value]\", \"$item[id]\")' style='color:$item[value]; margin-right:15px;$border'>";
$r .= " $item[name] ";
$r .= "</span></td>";
break;
+
+ case UNLOCK_WALL_ORIENTATION:
+ $checked = '';
+ if (intval($GLOBALS['wallOrientation']) == intval($item[value])) $checked = 'checked';
+ //$r .= "<td class='name_color_select'>";
+ $r .= "<td class='name_color_select'>";
+ $r .= "<input onClick='wallOrientationClick(this,\"$item[value]\", \"$item[id]\")' type='radio' name='wallOrientation' value='male' $checked>$item[name] ";
+ $r .= "</td>";
+ break;
case UNLOCK_EXTRAS:
$r .= "<td style='border: 1px solid gray;' class='name_color_select' title='$unlockTitle'>$item[name]</td>";
@@ -424,16 +464,17 @@ if (isset($unlocks)) { echo "<h2>Unlocks</h2>";
//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 "<br />"; if (!$viewer) {
+ //TODO add wall orientation
echo "
<form action='achievements' method='post' name='updateBadge'>
<input id='doupdate' type='hidden' name='doupdate' value='true' />
@@ -470,6 +512,8 @@ if (!$viewer) { <input id='selectColorID' type='hidden' name='selectColorID' value='' />
<input id='selectEmblem' type='hidden' name='selectEmblem' value='$wallEmblem' />
<input id='selectEmblemID' type='hidden' name='selectEmblemID' value='' />
+ <input id='selectOrientation' type='hidden' name='selectOrientation' value='$wallOrientation' />
+ <input id='selectOrientationID' type='hidden' name='selectOrientationID' value='' />
<input id='selectNameColor' type='hidden' name='selectNameColor' value='$nameColor' />
<input id='selectNameColorID' type='hidden' name='selectNameColorID' value='' />
<input type='submit' value='Save Changes' />
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+ " <div class='chatColumn1'>";
p = p+ " <span class='chatTimestamp' title='"+timestampDetails+"'>["+timestamp+"]</span>";
- p = p+ " <div class='grid_td chatBadge' style='float:left; width:35px; height:35px; background:"+chat.wallColor+" url(images/marks/"+chat.wallEmblem+");'>";
+ p = p+ " <div class='grid_td chatBadge' style='float:left; width:35px; height:35px; background:"+chat.wallColor+" url("+linkEmblem(chat.wallEmblem, chat.wallOrientation)+");'>";
p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
p = p+ " </div>";
p = p+ " </div>";
|