Skip to content

Commit

Permalink
libappfw|Client: Access UI style and renderer assets using PackageLoader
Browse files Browse the repository at this point in the history
Doomsday 2 built-in assets are now loaded as packages. Required
metadata was added to defaultstyle.pack, renderer.pack, and
lensflares.pack.
  • Loading branch information
skyjake committed Jul 3, 2014
1 parent 6a8cd59 commit 46638cb
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 21 deletions.
6 changes: 4 additions & 2 deletions doomsday/client/data/defaultstyle.pack/Info
@@ -1,4 +1,6 @@
# Default UI style for Doomsday.

name: Doomsday Default UI Style
labels: style
title: Doomsday Default UI Style
version: 1.15.0
license: GPL 3+
tags: ui style
7 changes: 4 additions & 3 deletions doomsday/client/data/lensflares.pack/Info
@@ -1,3 +1,4 @@
# Lens flares
name: Lens Flares
labels: core fx
title: Doomsday Default Lens Flares
version: 1.15.0
license: GPL 3+
tags: core fx
7 changes: 4 additions & 3 deletions doomsday/client/data/renderer.pack/Info
@@ -1,5 +1,6 @@
# General resources for the renderer

name: Doomsday Renderer
labels: core

title: Doomsday Renderer
version: 1.15.0
license: GPL 3+
tags: core
3 changes: 2 additions & 1 deletion doomsday/client/src/render/fx/lensflares.cpp
Expand Up @@ -24,6 +24,7 @@
#include "clientapp.h"

#include <de/concurrency.h>
#include <doomsday/console/cmd.h>
#include <de/Drawable>
#include <de/KdTreeAtlasAllocator>
#include <de/Log>
Expand Down Expand Up @@ -71,7 +72,7 @@ struct FlareData
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

Folder const &pack = App::fileSystem().find<Folder>("lensflares.pack");
Folder const &pack = App::rootFolder().locate<Folder>("/packs/lensflares/.");
images.addFromInfo(pack.locate<File>("images.dei"));

atlas.setAllocator(new KdTreeAtlasAllocator);
Expand Down
4 changes: 4 additions & 0 deletions doomsday/client/src/render/rendersystem.cpp
Expand Up @@ -97,6 +97,10 @@ DENG2_PIMPL(RenderSystem)
{
LOG_AS("RenderSystem");

// Load the required packages.
App::packageLoader().load("renderer");
App::packageLoader().load("lensflares");

loadAllShaders();
loadImages();

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/clientwindowsystem.cpp
Expand Up @@ -38,7 +38,7 @@ DENG2_PIMPL(ClientWindowSystem)
: Base(i)
{
self.setStyle(new ClientStyle);
self.style().load(App::fileSystem().find("defaultstyle.pack").path());
self.style().load(App::packageLoader().load("defaultstyle"));

settings.define(SettingsRegister::ConfigVariable, "window.main.showFps")
.define(SettingsRegister::IntCVar, "vid-fsaa", 1)
Expand Down
6 changes: 4 additions & 2 deletions doomsday/libappfw/include/de/framework/style.h
Expand Up @@ -27,6 +27,8 @@

namespace de {

class Package;

/**
* User interface style.
*/
Expand All @@ -39,9 +41,9 @@ class LIBAPPFW_PUBLIC Style
/**
* Loads a style from a resource pack.
*
* @param pack Absolute path of a resource pack containing the style.
* @param pack Package containing the style.
*/
void load(String const &pack);
void load(Package const &pack);

RuleBank const &rules() const;
FontBank const &fonts() const;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libappfw/src/baseguiapp.cpp
Expand Up @@ -32,7 +32,7 @@ static Value *Function_App_LoadFont(Context &, Function::ArgumentValues const &a
try
{
// Try to load the specific font.
Block data(App::fileSystem().root().locate<File const>(args.at(0)->asText()));
Block data(App::rootFolder().locate<File const>(args.at(0)->asText()));
int id;
id = QFontDatabase::addApplicationFontFromData(data);
if(id < 0)
Expand Down
15 changes: 7 additions & 8 deletions doomsday/libappfw/src/style.cpp
Expand Up @@ -23,6 +23,7 @@
#include <de/Record>
#include <de/Variable>
#include <de/RecordValue>
#include <de/Package>

namespace de {

Expand Down Expand Up @@ -50,19 +51,17 @@ DENG2_PIMPL(Style)
module.clear();
}

void load(String const &path)
void load(Package const &pack)
{
Folder const &pack = App::rootFolder().locate<Folder>(path);

if(CommandLine::ArgWithParams arg = App::commandLine().check("-fontsize", 1))
{
fonts.setFontSizeFactor(arg.params.at(0).toFloat());
}

rules.addFromInfo(pack.locate<File>("rules.dei"));
fonts.addFromInfo(pack.locate<File>("fonts.dei"));
colors.addFromInfo(pack.locate<File>("colors.dei"));
images.addFromInfo(pack.locate<File>("images.dei"));
rules .addFromInfo(pack.root().locate<File>("rules.dei"));
fonts .addFromInfo(pack.root().locate<File>("fonts.dei"));
colors.addFromInfo(pack.root().locate<File>("colors.dei"));
images.addFromInfo(pack.root().locate<File>("images.dei"));

// Update the subrecords of the native module.
module.add(new Variable("rules", new RecordValue(rules.names()), Variable::AllowRecord));
Expand All @@ -78,7 +77,7 @@ Style::Style() : d(new Instance(this))
Style::~Style()
{}

void Style::load(String const &pack)
void Style::load(Package const &pack)
{
d->clear();
d->load(pack);
Expand Down

0 comments on commit 46638cb

Please sign in to comment.