aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-15 13:46:43 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit06ccfd4b9af518707f51550a5b3fe6af313c3bd0 (patch)
treefa9f4223916c62845d1e15fbf1e7106cdbd643ba
parent626d85ea49801a40196292569848268dfb93621e (diff)
downloadscummvm-rg350-06ccfd4b9af518707f51550a5b3fe6af313c3bd0.tar.gz
scummvm-rg350-06ccfd4b9af518707f51550a5b3fe6af313c3bd0.tar.bz2
scummvm-rg350-06ccfd4b9af518707f51550a5b3fe6af313c3bd0.zip
CLOUD: Add icons in "/files" list
-rw-r--r--backends/networking/make_archive.py14
-rw-r--r--backends/networking/sdl_net/handlers/filespagehandler.cpp32
-rw-r--r--backends/networking/sdl_net/handlers/filespagehandler.h14
-rw-r--r--backends/networking/wwwroot.zipbin231402 -> 233020 bytes
-rw-r--r--backends/networking/wwwroot/icons/7z.pngbin0 -> 166 bytes
-rw-r--r--backends/networking/wwwroot/icons/dir.pngbin0 -> 150 bytes
-rw-r--r--backends/networking/wwwroot/icons/txt.pngbin0 -> 156 bytes
-rw-r--r--backends/networking/wwwroot/icons/unk.pngbin0 -> 142 bytes
-rw-r--r--backends/networking/wwwroot/icons/up.pngbin0 -> 161 bytes
-rw-r--r--backends/networking/wwwroot/icons/zip.pngbin0 -> 183 bytes
-rw-r--r--backends/networking/wwwroot/style.css4
11 files changed, 49 insertions, 15 deletions
diff --git a/backends/networking/make_archive.py b/backends/networking/make_archive.py
index a55a4bd6e6..64d314bedd 100644
--- a/backends/networking/make_archive.py
+++ b/backends/networking/make_archive.py
@@ -17,12 +17,14 @@ def buildArchive(archiveName):
print ("Building '" + archiveName + "' archive:")
os.chdir(archiveName)
- filenames = os.listdir('.')
- filenames.sort()
- for filename in filenames:
- if os.path.isfile(filename) and filename.endswith(ARCHIVE_FILE_EXTENSIONS):
- zf.write(filename, './' + filename)
- print (" Adding file: " + filename)
+ directories = ['.', './icons']
+ for d in directories:
+ filenames = os.listdir(d)
+ filenames.sort()
+ for filename in filenames:
+ if os.path.isfile(d + '/' + filename) and filename.endswith(ARCHIVE_FILE_EXTENSIONS):
+ zf.write(d + '/' + filename, d + '/' + filename)
+ print (" Adding file: " + d + '/' + filename)
os.chdir('../')
diff --git a/backends/networking/sdl_net/handlers/filespagehandler.cpp b/backends/networking/sdl_net/handlers/filespagehandler.cpp
index e519c5ac8b..1b8ab463bc 100644
--- a/backends/networking/sdl_net/handlers/filespagehandler.cpp
+++ b/backends/networking/sdl_net/handlers/filespagehandler.cpp
@@ -68,7 +68,7 @@ void FilesPageHandler::handle(Client &client) {
"<table>{content}</table>" \
"</body>" \
"</html>";
- Common::String itemTemplate = "<tr><td><a href=\"{link}\">{name}</a></td><td>{size}</td></tr>\n"; //TODO: load this template too?
+ Common::String itemTemplate = "<tr><td><img src=\"icons/{icon}\"/></td><td><a href=\"{link}\">{name}</a></td><td>{size}</td></tr>\n"; //TODO: load this template too?
// load stylish response page from the archive
Common::SeekableReadStream *const stream = HandlerUtils::getArchiveFile(FILES_PAGE_NAME);
@@ -99,8 +99,8 @@ void FilesPageHandler::handle(Client &client) {
bool FilesPageHandler::listDirectory(Common::String path, Common::String &content, const Common::String &itemTemplate) {
if (path == "" || path == "/") {
- addItem(content, itemTemplate, true, "/root/", _("File system root"));
- addItem(content, itemTemplate, true, "/saves/", _("Saved games"));
+ addItem(content, itemTemplate, IT_DIRECTORY, "/root/", _("File system root"));
+ addItem(content, itemTemplate, IT_DIRECTORY, "/saves/", _("Saved games"));
return true;
}
@@ -127,7 +127,7 @@ bool FilesPageHandler::listDirectory(Common::String path, Common::String &conten
filePath = "/";
else
filePath = parentPath(prefixToAdd + filePath);
- addItem(content, itemTemplate, true, filePath, _("Parent directory"));
+ addItem(content, itemTemplate, IT_PARENT_DIRECTORY, filePath, _("Parent directory"));
}
// fill the content
@@ -140,14 +140,32 @@ bool FilesPageHandler::listDirectory(Common::String path, Common::String &conten
filePath.erase(0, prefixToRemove.size());
filePath = prefixToAdd + filePath;
- addItem(content, itemTemplate, i->isDirectory(), filePath, name);
+ addItem(content, itemTemplate, detectType(i->isDirectory(), name), filePath, name);
}
return true;
}
-void FilesPageHandler::addItem(Common::String &content, const Common::String &itemTemplate, bool isDirectory, Common::String path, Common::String name, Common::String size) {
- Common::String item = itemTemplate;
+FilesPageHandler::ItemType FilesPageHandler::detectType(bool isDirectory, const Common::String &name) const {
+ if (isDirectory) return IT_DIRECTORY;
+ if (name.hasSuffix(".txt")) return IT_TXT;
+ if (name.hasSuffix(".zip")) return IT_ZIP;
+ if (name.hasSuffix(".7z")) return IT_7Z;
+ return IT_UNKNOWN;
+}
+
+void FilesPageHandler::addItem(Common::String &content, const Common::String &itemTemplate, ItemType itemType, Common::String path, Common::String name, Common::String size) {
+ Common::String item = itemTemplate, icon;
+ bool isDirectory = (itemType == IT_DIRECTORY || itemType == IT_PARENT_DIRECTORY);
+ switch (itemType) {
+ case IT_DIRECTORY: icon = "dir.png"; break;
+ case IT_PARENT_DIRECTORY: icon = "up.png"; break;
+ case IT_TXT: icon = "txt.png"; break;
+ case IT_ZIP: icon = "zip.png"; break;
+ case IT_7Z: icon = "7z.png"; break;
+ default: icon = "unk.png";
+ }
+ replace(item, "{icon}", icon);
replace(item, "{link}", (isDirectory ? "files?path=" : "download?path=") + LocalWebserver::urlEncodeQueryParameterValue(path));
replace(item, "{name}", name);
replace(item, "{size}", size);
diff --git a/backends/networking/sdl_net/handlers/filespagehandler.h b/backends/networking/sdl_net/handlers/filespagehandler.h
index ba132fd7ba..f102acd9fc 100644
--- a/backends/networking/sdl_net/handlers/filespagehandler.h
+++ b/backends/networking/sdl_net/handlers/filespagehandler.h
@@ -28,6 +28,15 @@
namespace Networking {
class FilesPageHandler: public FilesBaseHandler {
+ enum ItemType {
+ IT_DIRECTORY,
+ IT_PARENT_DIRECTORY,
+ IT_TXT,
+ IT_ZIP,
+ IT_7Z,
+ IT_UNKNOWN
+ };
+
void handle(Client &client);
/**
@@ -37,8 +46,11 @@ class FilesPageHandler: public FilesBaseHandler {
*/
bool listDirectory(Common::String path, Common::String &content, const Common::String &itemTemplate);
+ /** Helper method for detecting items' type. */
+ ItemType detectType(bool isDirectory, const Common::String &name) const;
+
/** Helper method for adding items into the files list. */
- void addItem(Common::String &content, const Common::String &itemTemplate, bool isDirectory, Common::String path, Common::String name, Common::String size = "");
+ void addItem(Common::String &content, const Common::String &itemTemplate, ItemType itemType, Common::String path, Common::String name, Common::String size = "");
public:
FilesPageHandler();
diff --git a/backends/networking/wwwroot.zip b/backends/networking/wwwroot.zip
index 3aa9bdda65..6f695e0639 100644
--- a/backends/networking/wwwroot.zip
+++ b/backends/networking/wwwroot.zip
Binary files differ
diff --git a/backends/networking/wwwroot/icons/7z.png b/backends/networking/wwwroot/icons/7z.png
new file mode 100644
index 0000000000..656e7e7c62
--- /dev/null
+++ b/backends/networking/wwwroot/icons/7z.png
Binary files differ
diff --git a/backends/networking/wwwroot/icons/dir.png b/backends/networking/wwwroot/icons/dir.png
new file mode 100644
index 0000000000..bcdec04a57
--- /dev/null
+++ b/backends/networking/wwwroot/icons/dir.png
Binary files differ
diff --git a/backends/networking/wwwroot/icons/txt.png b/backends/networking/wwwroot/icons/txt.png
new file mode 100644
index 0000000000..023d2ee24a
--- /dev/null
+++ b/backends/networking/wwwroot/icons/txt.png
Binary files differ
diff --git a/backends/networking/wwwroot/icons/unk.png b/backends/networking/wwwroot/icons/unk.png
new file mode 100644
index 0000000000..346eebecc3
--- /dev/null
+++ b/backends/networking/wwwroot/icons/unk.png
Binary files differ
diff --git a/backends/networking/wwwroot/icons/up.png b/backends/networking/wwwroot/icons/up.png
new file mode 100644
index 0000000000..2dc3df022b
--- /dev/null
+++ b/backends/networking/wwwroot/icons/up.png
Binary files differ
diff --git a/backends/networking/wwwroot/icons/zip.png b/backends/networking/wwwroot/icons/zip.png
new file mode 100644
index 0000000000..cdfc5763dd
--- /dev/null
+++ b/backends/networking/wwwroot/icons/zip.png
Binary files differ
diff --git a/backends/networking/wwwroot/style.css b/backends/networking/wwwroot/style.css
index e00a2bcd74..d8fcfd3654 100644
--- a/backends/networking/wwwroot/style.css
+++ b/backends/networking/wwwroot/style.css
@@ -85,4 +85,6 @@ html {
.modal input[type="submit"]:hover {
background: #F3F3F3;
cursor: pointer;
-} \ No newline at end of file
+}
+
+td img { vertical-align: middle; height: 20px; } \ No newline at end of file