mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Merge branch 'master' of github.com:hrydgard/native
Conflicts: ui/screen.cpp
This commit is contained in:
@@ -69,6 +69,17 @@ void NativeMix(short *audio, int num_samples);
|
||||
void NativeShutdownGraphics();
|
||||
void NativeShutdown();
|
||||
|
||||
// Called on app.onCreate and app.onDestroy (?). Tells the app to save/restore
|
||||
// light state. If app was fully rebooted between these calls, it's okay if some minor
|
||||
// state is lost (position in level) but the level currently playihg, or the song
|
||||
// currently being edited, or whatever, should be restored properly. In this case,
|
||||
// firstTime will be set so that appropriate action can be taken (or not taken when
|
||||
// it's not set).
|
||||
//
|
||||
// Note that NativeRestore is always called on bootup.
|
||||
void NativeRestoreState(bool firstTime); // onCreate
|
||||
void NativeSaveState(); // onDestroy
|
||||
|
||||
// Calls back into Java / SDL
|
||||
// These APIs must be implemented by every port (for example app-android.cpp, PCMain.cpp).
|
||||
// You are free to call these.
|
||||
|
||||
+7
-3
@@ -209,12 +209,16 @@ int main(int argc, char *argv[]) {
|
||||
PathAppend(path, (app_name + "\\").c_str());
|
||||
#else
|
||||
// Mac / Linux
|
||||
const char *path = getenv("HOME");
|
||||
if (!path) {
|
||||
char path[512];
|
||||
const char *the_path = getenv("HOME");
|
||||
if (!the_path) {
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
if (pwd)
|
||||
path = pwd->pw_dir;
|
||||
the_path = pwd->pw_dir;
|
||||
}
|
||||
strcpy(path, the_path);
|
||||
if (path[strlen(path)-1] != '/')
|
||||
strcat(path, "/");
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -18,10 +18,12 @@ class InlineFastList {
|
||||
void Add(T t) {
|
||||
data_[count_++] = t;
|
||||
}
|
||||
|
||||
void RemoveAt(int index) {
|
||||
data_[index] = data_[count_ - 1];
|
||||
count_--;
|
||||
}
|
||||
|
||||
void Remove(T t) { // Requires operator==
|
||||
for (int i = 0; i < count_; i++) {
|
||||
if (data_[i] == t) {
|
||||
|
||||
+1
-1
@@ -239,7 +239,7 @@ static std::string fromUnicode(const uint16_t *src, int len) {
|
||||
std::string str;
|
||||
str.resize(len);
|
||||
for (int i=0; i<len; i++) {
|
||||
str[i] = i > 255 ? ' ' : i;
|
||||
str[i] = src[i] > 255 ? ' ' : src[i];
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
+8
-8
@@ -61,8 +61,7 @@ bool ReadFileToString(bool text_file, const char *filename, std::string &str)
|
||||
|
||||
#ifndef METRO
|
||||
|
||||
size_t getFilesInDir(const char *directory, std::vector<std::string> *files)
|
||||
{
|
||||
size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files) {
|
||||
size_t foundEntries = 0;
|
||||
#ifdef _WIN32
|
||||
// Find the first file in the directory.
|
||||
@@ -72,10 +71,9 @@ size_t getFilesInDir(const char *directory, std::vector<std::string> *files)
|
||||
#else
|
||||
HANDLE hFind = FindFirstFile((std::string(directory) + "\\*").c_str(), &ffd);
|
||||
#endif
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
FindClose(hFind);
|
||||
return foundEntries;
|
||||
return 0;
|
||||
}
|
||||
// windows loop
|
||||
do
|
||||
@@ -98,8 +96,10 @@ size_t getFilesInDir(const char *directory, std::vector<std::string> *files)
|
||||
((virtualName[0] == '.') && (virtualName[1] == '.') &&
|
||||
(virtualName[2] == '\0')))
|
||||
continue;
|
||||
|
||||
files->push_back(std::string(directory) + virtualName);
|
||||
FileInfo info;
|
||||
info.name = std::string(directory) + virtualName;
|
||||
info.isDirectory = false; // TODO
|
||||
files->push_back(info);
|
||||
#ifdef _WIN32
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
FindClose(hFind);
|
||||
@@ -136,4 +136,4 @@ std::string getDir(const std::string &path)
|
||||
if (cutpath[i] == '\\') cutpath[i] = '/';
|
||||
}
|
||||
return cutpath;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -8,7 +8,14 @@ bool writeStringToFile(bool text_file, const std::string &str, const char *filen
|
||||
bool readFileToString(bool text_file, const char *filename, std::string &str);
|
||||
|
||||
// Beginnings of a directory utility system. TODO: Improve.
|
||||
size_t getFilesInDir(const char *directory, std::vector<std::string> *files);
|
||||
|
||||
struct FileInfo
|
||||
{
|
||||
std::string name;
|
||||
bool isDirectory;
|
||||
};
|
||||
|
||||
size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files);
|
||||
void deleteFile(const char *file);
|
||||
|
||||
std::string getDir(const std::string &path);
|
||||
|
||||
@@ -18,7 +18,7 @@ void unregister_gl_resource_holder(GfxResourceHolder *holder) {
|
||||
if (holders) {
|
||||
holders->remove(holder);
|
||||
} else {
|
||||
WLOG("GL resource holder not initialized, cannot unregister resource");
|
||||
WLOG("GL resource holder not initialized or already shutdown, cannot unregister resource");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ set(SRCS
|
||||
lin/matrix4x4.cpp
|
||||
lin/vec3.cpp
|
||||
lin/quat.cpp
|
||||
lin/aabb.cpp
|
||||
)
|
||||
|
||||
set(SRCS ${SRCS})
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "input/input_state.h"
|
||||
#include "ui/screen.h"
|
||||
|
||||
ScreenManager screenManager;
|
||||
|
||||
Screen::Screen() { }
|
||||
Screen::~Screen() { }
|
||||
|
||||
|
||||
@@ -71,6 +71,3 @@ private:
|
||||
// Used for options, in-game menus and other things you expect to be able to back out from onto something.
|
||||
std::list<Screen *> dialog_;
|
||||
};
|
||||
|
||||
// Yeah, an old school non enforced singleton. Good enough.
|
||||
extern ScreenManager screenManager;
|
||||
|
||||
@@ -248,7 +248,7 @@ void StringVectorListAdapter::drawItem(int item, int x, int y, int w, int h, boo
|
||||
ui_draw2d.DrawTextShadow(theme.uiFont, (*items_)[item].c_str(), x + UI_SPACE , y, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
}
|
||||
|
||||
int UIList(int id, int x, int y, int w, int h, UIListAdapter *adapter, UIListState *state) {
|
||||
int UIList::Do(int id, int x, int y, int w, int h, UIListAdapter *adapter) {
|
||||
const int item_h = 64;
|
||||
|
||||
int clicked = 0;
|
||||
@@ -262,12 +262,12 @@ int UIList(int id, int x, int y, int w, int h, UIListAdapter *adapter, UIListSta
|
||||
}
|
||||
|
||||
// If button is hot and active, but mouse button is not
|
||||
// down, the user must have clicked the button.
|
||||
// down, the user must have clicked a list item (unless after the last item).
|
||||
if (uistate.mousedown[i] == 0 &&
|
||||
uistate.hotitem[i] == id &&
|
||||
uistate.activeitem[i] == id &&
|
||||
state->selected != -1) {
|
||||
clicked = 1;
|
||||
uistate.hotitem[i] == id &&
|
||||
uistate.activeitem[i] == id &&
|
||||
selected != -1) {
|
||||
clicked = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,13 +275,15 @@ int UIList(int id, int x, int y, int w, int h, UIListAdapter *adapter, UIListSta
|
||||
int itemHeight = adapter->itemHeight(0);
|
||||
int numItems = adapter->getCount();
|
||||
for (int i = 0; i < numItems; i++) {
|
||||
int item_y = y + i * itemHeight - state->scrollY;
|
||||
if (uistate.mousedown && adapter->itemEnabled(i) && item_y >= y - itemHeight && item_y <= y + h &&
|
||||
UIRegionHit(i, x, item_y, w, h, 0)) {
|
||||
// ultra fast touch response
|
||||
state->selected = i;
|
||||
int item_y = y + i * itemHeight - scrollY;
|
||||
if (uistate.mousedown &&
|
||||
adapter->itemEnabled(i) &&
|
||||
item_y >= y - itemHeight &&
|
||||
item_y <= y + h &&
|
||||
UIRegionHit(i, x, item_y, w, h, 0)) {
|
||||
selected = i;
|
||||
}
|
||||
adapter->drawItem(i, x, item_y, w, itemHeight, i == state->selected);
|
||||
adapter->drawItem(i, x, item_y, w, itemHeight, i == selected);
|
||||
}
|
||||
uistate.lastwidget = id;
|
||||
|
||||
|
||||
@@ -162,18 +162,12 @@ public:
|
||||
|
||||
class StringVectorListAdapter : public UIListAdapter {
|
||||
public:
|
||||
StringVectorListAdapter(std::vector<std::string> *items) : items_(items) {}
|
||||
StringVectorListAdapter(const std::vector<std::string> *items) : items_(items) {}
|
||||
virtual size_t getCount() const { return items_->size(); }
|
||||
virtual void drawItem(int item, int x, int y, int w, int h, bool active) const;
|
||||
|
||||
private:
|
||||
std::vector<std::string> *items_;
|
||||
};
|
||||
|
||||
struct UIListState {
|
||||
UIListState() : scrollY(0.0f), selected(-1) {}
|
||||
float scrollY;
|
||||
int selected;
|
||||
const std::vector<std::string> *items_;
|
||||
};
|
||||
|
||||
|
||||
@@ -205,9 +199,20 @@ void UIText(int x, int y, const char *text, uint32_t color, float scale = 1.0f,
|
||||
// Slide choice, like the Angry Birds level selector. Not yet working.
|
||||
void UISlideChoice(int id, int y, const SlideItem *items, int numItems, UISlideState *state);
|
||||
|
||||
// List view.
|
||||
// return -1 = no selection
|
||||
int UIList(int id, int x, int y, int w, int h, UIListAdapter *adapter, UIListState *state);
|
||||
|
||||
class UIList {
|
||||
public:
|
||||
UIList() : scrollY(0.0f), startDragY(0.0f), dragFinger(-1), selected(-1) {}
|
||||
float scrollY;
|
||||
float startDragY;
|
||||
int dragFinger;
|
||||
int selected;
|
||||
// List view.
|
||||
// return -1 = no selection
|
||||
int Do(int id, int x, int y, int w, int h, UIListAdapter *adapter);
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(UIList);
|
||||
};
|
||||
|
||||
// Call at end of frame.
|
||||
// Do this afterwards (or similar):
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
set(SRCS
|
||||
bits/bits.cpp
|
||||
bits/varint.cpp
|
||||
random/perlin.cpp
|
||||
hash/hash.cpp
|
||||
)
|
||||
|
||||
set(SRCS ${SRCS})
|
||||
|
||||
add_library(util STATIC ${SRCS})
|
||||
|
||||
if(UNIX)
|
||||
add_definitions(-fPIC)
|
||||
endif(UNIX)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace varint {
|
||||
|
||||
void Encode32(uint32 value, char **dest) {
|
||||
void Encode32(uint32_t value, char **dest) {
|
||||
// Simple varint
|
||||
char *p = *dest;
|
||||
while (value > 127) {
|
||||
@@ -13,8 +13,8 @@ void Encode32(uint32 value, char **dest) {
|
||||
*dest = p;
|
||||
}
|
||||
|
||||
uint32 Decode32(const char **ptr) {
|
||||
uint32 value = 0;
|
||||
uint32_t Decode32(const char **ptr) {
|
||||
uint32_t value = 0;
|
||||
const char *p = *ptr;
|
||||
while (true) {
|
||||
uint8 b = *p++;
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
#ifndef _UTIL_BITS_VARINT
|
||||
#define _UTIL_BITS_VARINT
|
||||
|
||||
#include "base/base.h"
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace varint {
|
||||
|
||||
void Encode32(uint32 value, char **dest);
|
||||
uint32 Decode32(const char **ptr);
|
||||
void Encode32(uint32_t value, char **dest);
|
||||
uint32_t Decode32(const char **ptr);
|
||||
|
||||
} // namespace varint
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include "base/base.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "util/hash/hash.h"
|
||||
|
||||
namespace hash {
|
||||
|
||||
Reference in New Issue
Block a user