|
From: <tre...@us...> - 2007-10-21 16:11:39
|
Revision: 526
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=526&view=rev
Author: trevorolio
Date: 2007-10-21 09:11:36 -0700 (Sun, 21 Oct 2007)
Log Message:
-----------
INCLUDES A NEW DB SCHEMA. Dump your old db and make clean.
For those who don't want to break out photoshop to get a new look, added the capability to select from a set of textures included in the body data jar.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/AccountPersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyConfigurationRecord.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyPersistTasks.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java
maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/AccountPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/AccountPersistTasks.java 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/AccountPersistTasks.java 2007-10-21 16:11:36 UTC (rev 526)
@@ -143,7 +143,7 @@
if(bodyDataRecords.length == 0){
throw new IllegalStateException("No body data records!");
}
- BodyConfigurationRecord bodyConfRecord = new BodyConfigurationRecord(username, "Body", bodyDataRecords[0].getBodyDataID());
+ BodyConfigurationRecord bodyConfRecord = new BodyConfigurationRecord(username, "Body", bodyDataRecords[0].getBodyDataID(), null);
hibernateSession.save(bodyConfRecord);
record = new AccountRecord(username, accountlevel, email, bodyConfRecord.getBodyConfigurationID());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyConfigurationRecord.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyConfigurationRecord.java 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyConfigurationRecord.java 2007-10-21 16:11:36 UTC (rev 526)
@@ -12,16 +12,19 @@
private long bodyDataID = -1;
+ private String baseTextureName = null;
+
public BodyConfigurationRecord(){
}
- public BodyConfigurationRecord(String ownerUsername, String displayName, long bodyDataID){
+ public BodyConfigurationRecord(String ownerUsername, String displayName, long bodyDataID, String baseTextureName){
ArgumentUtils.assertNotEmpty(ownerUsername);
this.ownerUsername = ownerUsername;
ArgumentUtils.assertNotEmpty(displayName);
this.displayName = displayName;
ArgumentUtils.assertNotNegative(bodyDataID);
this.bodyDataID = bodyDataID;
+ this.baseTextureName = baseTextureName;
}
public long getBodyConfigurationID() {
@@ -40,6 +43,14 @@
this.ownerUsername = ownerUsername;
}
+ public String getBaseTextureName() {
+ return baseTextureName;
+ }
+
+ public void setBaseTextureName(String baseTextureName) {
+ this.baseTextureName = baseTextureName;
+ }
+
public String getDisplayName() {
return displayName;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyPersistTasks.java 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/BodyPersistTasks.java 2007-10-21 16:11:36 UTC (rev 526)
@@ -72,7 +72,7 @@
public static BodyConfigurationRecord createBodyConfiguration(final String username, final String displayName, final long bodyDataID, SessionFactory sessionFactory) throws PersistException {
HibernateTask task = new HibernateTask() {
public Object run(Session session) throws PersistException {
- BodyConfigurationRecord record = new BodyConfigurationRecord(username, displayName, bodyDataID);
+ BodyConfigurationRecord record = new BodyConfigurationRecord(username, displayName, bodyDataID, null);
session.save(record);
return record;
}
@@ -188,7 +188,7 @@
if(username.startsWith(WebConstants.GUEST_COOKIE_PREFIX)){ //fake up a configuration for our guests
Query bodyDataQuery = session.getNamedQuery(BODY_DATA);
BodyDataRecord[] bodyDataRecs = (BodyDataRecord[])bodyDataQuery.list().toArray(new BodyDataRecord[0]);
- BodyConfigurationDocument doc = new BodyConfigurationDocument(0, username, "Guest Body", bodyDataRecs[0].getBodyDataID());
+ BodyConfigurationDocument doc = new BodyConfigurationDocument(0, username, "Guest Body", bodyDataRecs[0].getBodyDataID(), null);
return doc;
}
@@ -239,6 +239,16 @@
dirty = true;
configRec.setBodyDataID(proposedDoc.getBodyDataID());
}
+ if((configRec.getBaseTextureName() == null && proposedDoc.getBaseTextureName() != null) || (configRec.getBaseTextureName() != null && proposedDoc.getBaseTextureName() == null)){
+ dirty = true;
+ configRec.setBaseTextureName(proposedDoc.getBaseTextureName());
+ } else if(configRec.getBaseTextureName() != null && !configRec.getBaseTextureName().equals(proposedDoc.getBaseTextureName())){
+ dirty = true;
+ configRec.setBaseTextureName(proposedDoc.getBaseTextureName());
+ } else if(proposedDoc.getBaseTextureName() != null && !proposedDoc.getBaseTextureName().equals(configRec.getBaseTextureName())){
+ dirty = true;
+ configRec.setBaseTextureName(proposedDoc.getBaseTextureName());
+ }
if(dirty){
session.update(configRec);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-10-21 16:11:36 UTC (rev 526)
@@ -1023,7 +1023,7 @@
private class SimBodyConfiguration extends BodyConfiguration {
public SimBodyConfiguration() {
- super(1, "Sim Body", 1);
+ super(1, "Sim Body", 1, null);
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/AccountServlet.java 2007-10-21 16:11:36 UTC (rev 526)
@@ -229,27 +229,6 @@
return;
}
- public void doHead(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws ServletException, IOException, PersistException {
- BodyConfigurationRecord configRecord = getBodyConfigurationRecord(request, authedAccount, pathElements);
- if (configRecord == null) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- String mediaName = MediaService.getBodyTextureName(configRecord.getBodyConfigurationID());
- long length = getMediaService().getSize(mediaName);
- if (length == -1) {
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- long lastModified = getMediaService().getLastModified(mediaName);
- setCachable(response);
- response.setStatus(HttpServletResponse.SC_OK);
- response.setContentLength((int) length);
- response.setDateHeader("Last-Modified", lastModified);
- }
-
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements, AccountRecord authedAccount) throws PersistException, IOException {
BodyConfigurationRecord configRecord = getBodyConfigurationRecord(request, authedAccount, pathElements);
if (configRecord == null) {
@@ -262,7 +241,6 @@
return;
}
response.setStatus(HttpServletResponse.SC_OK);
- setCachable(response);
if (data.getMimeType() != null) {
response.setContentType(data.getMimeType());
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/xml/server/DocumentFactory.java 2007-10-21 16:11:36 UTC (rev 526)
@@ -78,7 +78,7 @@
}
public static BodyConfigurationDocument documentFromRecord(BodyConfigurationRecord record, BodySettingRecord[] settingRecords) {
- BodyConfigurationDocument doc = new BodyConfigurationDocument(record.getBodyConfigurationID(), record.getOwnerUsername(), record.getDisplayName(), record.getBodyDataID());
+ BodyConfigurationDocument doc = new BodyConfigurationDocument(record.getBodyConfigurationID(), record.getOwnerUsername(), record.getDisplayName(), record.getBodyDataID(), record.getBaseTextureName());
for (int i = 0; i < settingRecords.length; i++) {
doc.addBodySetting(settingRecords[i].getSettingName(), settingRecords[i].getSetting());
}
Modified: maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/resources/hibernate/migration-1.xml 2007-10-21 16:11:36 UTC (rev 526)
@@ -156,6 +156,7 @@
<property name="ownerUsername" not-null="true" />
<property name="displayName" not-null="true" />
<property name="bodyDataID" />
+ <property name="baseTextureName" />
</class>
<class name="com.ogoglio.persist.BodySettingRecord"
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/body.html 2007-10-21 16:11:36 UTC (rev 526)
@@ -4,6 +4,7 @@
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="/og/ogoglio.js"></script>
<script type="text/javascript" src="site.js"></script>
+<script type="text/javascript" src="webtoolkit.aim.js"></script>
<title>Ogoglio Example: body</title>
<style type="text/css">
@@ -78,6 +79,7 @@
var leftControlDiv = null;
var rightControlDiv = null;
var bottomControlDiv = null;
+var textureSelectionDiv = null;
var textureForm = null;
var morphControls = null;
var animationControls = null;
@@ -143,8 +145,42 @@
animationHTML += "<form onsubmit='playAnimation(\"" + animationNames[i] + "\"); return false;'><input type='submit' value='" + animationNames[i] + "'/></form>";
}
animationControls.innerHTML = animationHTML;
+
+ var textureNames = editor.getBaseTextureNames();
+ var baseTextureName = bodyXML.getAttribute("basetexturename");
+
+ var textureHTML = "<form id='textureSelectForm' action='body.html' method='get' onsubmit='return false;'>";
+ textureHTML += "<select id='textureSelect' onchange='textureSelectGo();' name='textureSelect'>";
+ if(baseTextureName == null){
+ textureHTML += "<option selected='selected' value='Default'>Default</option>";
+ } else {
+ textureHTML += "<option value='Default'>Default</option>";
+ }
+ for(var i=0; i < textureNames.length; i++){
+ var selectedText = textureNames[i] == baseTextureName ? "selected='selected'" : "";
+ textureHTML += "<option " + selectedText + " value='" + textureNames[i] + "'>" + textureNames[i] + "</option>";
+ }
+ textureHTML += "</select></form>";
+ textureSelectionDiv.innerHTML = textureHTML;
}
+function textureSelectGo(){
+ var textureSelectForm = document.getElementById("textureSelectForm");
+ var selectedTextureName = textureSelectForm.textureSelect.options[textureSelectForm.textureSelect.selectedIndex].value;
+ var currentTextureName = bodyXML.getAttribute("basetexturename");
+ if(currentTextureName == selectedTextureName || (currentTextureName == null && selectedTextureName == "Default")){
+ return;
+ }
+ var editor = document.getElementById("viewer");
+ if(selectedTextureName == "Default"){
+ editor.setBaseTexture(null);
+ } else {
+ editor.setBaseTexture(selectedTextureName);
+ }
+ requestDefaultBodyDocument(authedUsername, handleBodyConfiguration);
+ return true;
+}
+
function playAnimation(animationName){
var editor = document.getElementById("viewer");
editor.playAnimation(animationName);
@@ -179,11 +215,30 @@
appletDiv.innerHTML = html;
}
+function startedTextureForm() {
+ return true;
+}
+
+function completedTextureForm(response) {
+ repaintTexture();
+}
+
function handleTextureForm(){
- setTimeout("repaintTexture();", 5000);
+ AIM.submit(textureForm, {'onStart' : startedTextureForm, 'onComplete' : completedTextureForm})
return true;
}
+function textureDeleteGo(){
+ if(bodyXML == null){
+ return;
+ }
+ deleteBodyTexture(authedUsername, bodyXML.getAttribute("bodyconfigurationid"), handleTextureDelete);
+}
+
+function handleTextureDelete(){
+ repaintTexture();
+}
+
function repaintTexture(){
var ogViewer = document.getElementById("viewer");
ogViewer.updateTextures();
@@ -206,6 +261,7 @@
leftControlDiv = document.getElementById("leftControlDiv");
rightControlDiv = document.getElementById("rightControlDiv");
bottomControlDiv = document.getElementById("bottomControlDiv");
+ textureSelectionDiv = document.getElementById("textureSelectionDiv");
textureForm = document.getElementById("textureForm");
morphControls = document.getElementById("morphControls");
animationControls = document.getElementById("animationControls");
@@ -233,10 +289,13 @@
<div id="rightControlDiv">
<div id="animationControls"> </div>
+ <div id="textureSelectionDiv"> </div>
+
<form id="textureForm" onsubmit="handleTextureForm();" target="textureTargetFrame" action="" enctype="multipart/form-data" method="post">
<input type="file" size="7" name="textureData" />
<input type="submit" value="upload custom skin" />
</form>
+ <form id="textureDeleteForm" onsubmit="textureDeleteGo(); return false;"><input type="submit" value="delete custom skin"/></form>
<iframe id="textureTargetFrame" name="textureTargetFrame" style="width: 1px; height: 1px;"></iframe>
</div>
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-10-21 16:11:36 UTC (rev 526)
@@ -781,6 +781,12 @@
manager.send(xmlString);
}
+function deleteBodyTexture(username, bodyID, listener){
+ var manager = new XMLRequestManager(appPath + "/account/" + username + "/body/" + bodyID + "/texture", new BasicHTTPListener(listener));
+ manager.setMethod("DELETE");
+ manager.send();
+}
+
// BEGIN POSSESSION UTILS
function requestPossession(username, possessionID, listener){
Modified: maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java
===================================================================
--- maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java 2007-10-21 16:11:31 UTC (rev 525)
+++ maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java 2007-10-21 16:11:36 UTC (rev 526)
@@ -128,7 +128,7 @@
}
public BodyConfigurationDocument getDefaultBodyConfigurationDocument(String username) {
- return new BodyConfigurationDocument(1, username, "Script Test Body", 1);
+ return new BodyConfigurationDocument(1, username, "Script Test Body", 1, null);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|