Exemple #1
0
		ClientUI::ClientUI(client::IRenderer *r, client::IAudioDevice *a, IFont *font, Client *client) :
		renderer(r),
		audioDevice(a),
		font(font),client(client){
			SPADES_MARK_FUNCTION();
			if(r == NULL)
				SPInvalidArgument("r");
			if(a == NULL)
				SPInvalidArgument("a");
			
			helper.Set(new ClientUIHelper(this), false);
			
			static ScriptFunction uiFactory("ClientUI@ CreateClientUI(Renderer@, AudioDevice@, Font@, ClientUIHelper@)");
			{
				ScriptContextHandle ctx = uiFactory.Prepare();
				ctx->SetArgObject(0, renderer);
				ctx->SetArgObject(1, audioDevice);
				ctx->SetArgObject(2, font);
				ctx->SetArgObject(3, &*helper);
				
				ctx.ExecuteChecked();
				ui = reinterpret_cast<asIScriptObject *>(ctx->GetReturnObject());
			}
			
		}
Exemple #2
0
		void Runner::OverrideVideoSize(int width, int height) {
			if(width < 1 || width > 16384)
				SPInvalidArgument("width");
			if(height < 1 || height > 16384)
				SPInvalidArgument("height");
			m_videoWidth = width;
			m_videoHeight = height;
		}
Exemple #3
0
	StdStream::StdStream(FILE *f, bool ac):
	handle(f), autoClose(ac){
		SPADES_MARK_FUNCTION();
		
		if(!f)
			SPInvalidArgument("f");
	}
Exemple #4
0
		StartupScreen::StartupScreen(client::IRenderer *r, client::IAudioDevice *a,
		                             StartupScreenHelper *helper, client::FontManager *fontManager)
		    : renderer(r),
		      audioDevice(a),
		      fontManager(fontManager),
		      startRequested(false),
		      helper(helper) {
			SPADES_MARK_FUNCTION();
			if (r == NULL)
				SPInvalidArgument("r");
			if (a == NULL)
				SPInvalidArgument("a");

			helper->BindStartupScreen(this);

			DoInit();
		}
Exemple #5
0
		MainScreen::MainScreen(client::IRenderer *r, client::IAudioDevice *a) :
		renderer(r),
		audioDevice(a){
			SPADES_MARK_FUNCTION();
			if(r == NULL)
				SPInvalidArgument("r");
			if(a == NULL)
				SPInvalidArgument("a");
			
			font = client::CreateGuiFont(renderer);
			
			helper = new MainScreenHelper(this);
						
			// first call to RunFrame tends to have larger dt value.
			// so this value is set in the first call.
			timeToStartInitialization = 1000.f;
		}
		int GLProgramAttribute::operator()(spades::draw::GLProgram *prog){
			
			SPADES_MARK_FUNCTION_DEBUG();
			
			if(prog == NULL) {
				SPInvalidArgument("prog");
			}
			if(prog != last){
				last = prog;
				loc = last->GetDevice()->GetAttribLocation(last->GetHandle(), name.c_str());
				if(loc == -1){
					fprintf(stderr, "WARNING: GLSL attribute '%s' not found\n", name.c_str());
				}
			}
			return loc;
		}
	std::vector<std::string> FileManager::EnumFiles(const char *path) {
		std::vector<std::string> list;
		std::set<std::string> set;
		if(!path) SPInvalidArgument("path");

		for(auto *fs: g_fileSystems){
			std::vector<std::string> l = fs->EnumFiles(path);
			for(size_t i = 0; i < l.size(); i++)
				set.insert(l[i]);
		}

		for(auto& s: set)
			list.push_back(s);

		return list;
	}
	bool FileManager::FileExists(const char *fn) {
		SPADES_MARK_FUNCTION();
		if(!fn) SPInvalidArgument("fn");

		for(auto *fs: g_fileSystems){
			if(fs->FileExists(fn))
				return true;
		}

		// check weak files, too
		auto weak_fn = std::string(fn) + ".weak";
		for(auto *fs: g_fileSystems){
			if(fs->FileExists(weak_fn.c_str()))
				return true;
		}

		return false;
	}
		void AsyncRenderer::DrawImage(client::IImage *image,
								   const spades::Vector2 &outTopLeft,
								   const spades::Vector2 &outTopRight,
								   const spades::Vector2 &outBottomLeft,
								   const spades::AABB2 &inRect) {
			SPADES_MARK_FUNCTION();
			
			if(!image){
				SPInvalidArgument("image");
			}
			
			rcmds::DrawImage *cmd = generator->AllocCommand<rcmds::DrawImage>();
			cmd->img = image;
			image->AddRef();
			cmd->outTopLeft = outTopLeft;
			cmd->outTopRight = outTopRight;
			cmd->outBottomLeft = outBottomLeft;
			cmd->inRect = inRect;
		}
Exemple #10
0
	IStream *FileManager::OpenForReading(const char *fn) {
		SPADES_MARK_FUNCTION();
		if(!fn) SPInvalidArgument("fn");
		if(fn[0] == 0) SPFileNotFound(fn);

		// check each file systems
		for(auto *fs: g_fileSystems){
			if(fs->FileExists(fn))
				return fs->OpenForReading(fn);
		}

		// check weak files, too
		auto weak_fn = std::string(fn) + ".weak";
		for(auto *fs: g_fileSystems){
			if(fs->FileExists(weak_fn.c_str()))
				return fs->OpenForReading(weak_fn.c_str());
		}

		SPFileNotFound(fn);
	}
Exemple #11
0
	IStream *FileManager::OpenForWriting(const char *fn) {
		SPADES_MARK_FUNCTION();
		if(!fn) SPInvalidArgument("fn");
		if(fn[0] == 0) SPFileNotFound(fn);
		for(auto *fs: g_fileSystems){
			if(fs->FileExists(fn))
				return fs->OpenForWriting(fn);
		}

		// FIXME: handling of weak files

		// create file
		for(auto *fs: g_fileSystems){
			try{
				return fs->OpenForWriting(fn);
			}catch(...){
			}
		}

		SPRaise("No filesystem is writable");
	}
Exemple #12
0
	void FileManager::AppendFileSystem(spades::IFileSystem *fs){
		SPADES_MARK_FUNCTION();
		if(!fs) SPInvalidArgument("fs");

		g_fileSystems.push_back(fs);
	}