summaryrefslogtreecommitdiff
path: root/src/loadstatus.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/loadstatus.h')
-rw-r--r--src/loadstatus.h163
1 files changed, 0 insertions, 163 deletions
diff --git a/src/loadstatus.h b/src/loadstatus.h
deleted file mode 100644
index 06d515ae3..000000000
--- a/src/loadstatus.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-Minetest-c55
-Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#ifndef LOADSTATUS_HEADER
-#define LOADSTATUS_HEADER
-
-class LoadStatus
-{
- bool ready;
- JMutex ready_mutex;
-
- u32 done;
- JMutex done_mutex;
-
- u32 todo;
- JMutex todo_mutex;
-
- wchar_t *text;
- JMutex text_mutex;
-
-public:
-
- LoadStatus(bool a_ready=false, u32 a_done=0, u32 a_todo=0)
- {
- ready = a_ready;
- done = a_done;
- todo = a_todo;
- text = NULL;
- ready_mutex.Init();
- done_mutex.Init();
- todo_mutex.Init();
- text_mutex.Init();
- }
-
- void setReady(bool a_ready)
- {
- ready_mutex.Lock();
- ready = a_ready;
- ready_mutex.Unlock();
- }
-
- bool getReady(void)
- {
- ready_mutex.Lock();
- bool a_ready = ready;
- ready_mutex.Unlock();
- return a_ready;
- }
-
- void setDone(u32 a_done)
- {
- done_mutex.Lock();
- done = a_done;
- done_mutex.Unlock();
- }
-
- u32 getDone(void)
- {
- done_mutex.Lock();
- u32 a_done = done;
- done_mutex.Unlock();
- return a_done;
- }
-
- void setTodo(u32 a_todo)
- {
- todo_mutex.Lock();
- todo = a_todo;
- todo_mutex.Unlock();
- }
-
- u32 getTodo(void)
- {
- todo_mutex.Lock();
- u32 a_todo = todo;
- todo_mutex.Unlock();
- return a_todo;
- }
-
- /*
- Copies the text if not NULL,
- If NULL; sets text to NULL.
- */
- void setText(const wchar_t *a_text)
- {
- text_mutex.Lock();
- if(text != NULL)
- free(text);
- if(a_text == NULL){
- text = NULL;
- text_mutex.Unlock();
- return;
- }
- u32 len = wcslen(a_text);
- text = (wchar_t*)malloc(sizeof(wchar_t) * (len+1));
- if(text == NULL) throw;
- swprintf(text, len+1, L"%ls", a_text);
- text_mutex.Unlock();
- }
-
- /*
- Return value must be free'd
- Return value can be NULL
- */
- wchar_t * getText()
- {
- text_mutex.Lock();
- if(text == NULL){
- text_mutex.Unlock();
- return NULL;
- }
- u32 len = wcslen(text);
- wchar_t *b_text = (wchar_t*)malloc(sizeof(wchar_t) * (len+1));
- if(b_text == NULL) throw;
- swprintf(b_text, len+1, L"%ls", text);
- text_mutex.Unlock();
- return b_text;
- }
-
- /*
- Return value must be free'd
- */
- wchar_t * getNiceText()
- {
- const wchar_t *defaulttext = L"Loading";
- wchar_t *t = getText();
- u32 maxlen = 20; // " (%i/%i)"
- if(t != NULL)
- maxlen += wcslen(t);
- else
- maxlen += wcslen(defaulttext);
- wchar_t *b_text = (wchar_t*)malloc(sizeof(wchar_t) * (maxlen+1));
- if(b_text == NULL) throw;
- if(t != NULL)
- swprintf(b_text, maxlen+1, L"%ls (%i/%i)",
- t, getDone(), getTodo());
- else
- swprintf(b_text, maxlen+1, L"%ls (%i/%i)",
- defaulttext, getDone(), getTodo());
- if(t != NULL)
- free(t);
- return b_text;
- }
-};
-
-#endif
-