mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
merge default into minor
--HG-- branch : minor
This commit is contained in:
@@ -228,6 +228,8 @@ namespace event
|
||||
{"power", love::keyboard::Keyboard::KEY_POWER},
|
||||
{"euro", love::keyboard::Keyboard::KEY_EURO},
|
||||
{"undo", love::keyboard::Keyboard::KEY_UNDO},
|
||||
|
||||
{"unknown", love::keyboard::Keyboard::KEY_UNKNOWN},
|
||||
};
|
||||
|
||||
StringMap<love::keyboard::Keyboard::Key, love::keyboard::Keyboard::KEY_MAX_ENUM> Event::keys(Event::keyEntries, sizeof(Event::keyEntries));
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace sdl
|
||||
case Event::TYPE_KEY_PRESSED:
|
||||
e.type = SDL_KEYDOWN;
|
||||
e.key.keysym.unicode = (Uint16)m.keyboard.u;
|
||||
return keys.find(m.keyboard.k, e.key.keysym.sym);;
|
||||
return keys.find(m.keyboard.k, e.key.keysym.sym);
|
||||
case Event::TYPE_KEY_RELEASED:
|
||||
e.type = SDL_KEYUP;
|
||||
return keys.find(m.keyboard.k, e.key.keysym.sym);
|
||||
@@ -290,6 +290,8 @@ namespace sdl
|
||||
{ love::keyboard::Keyboard::KEY_POWER, SDLK_POWER },
|
||||
{ love::keyboard::Keyboard::KEY_EURO, SDLK_EURO },
|
||||
{ love::keyboard::Keyboard::KEY_UNDO, SDLK_UNDO },
|
||||
|
||||
{ love::keyboard::Keyboard::KEY_UNKNOWN, SDLK_UNKNOWN },
|
||||
};
|
||||
|
||||
EnumMap<love::keyboard::Keyboard::Key, SDLKey, love::keyboard::Keyboard::KEY_MAX_ENUM> Event::keys(Event::keyEntries, sizeof(Event::keyEntries));
|
||||
|
||||
@@ -110,8 +110,8 @@ namespace physfs
|
||||
{
|
||||
bool isOpen = (file != 0);
|
||||
|
||||
if(!isOpen)
|
||||
open(READ);
|
||||
if(!isOpen && !open(READ))
|
||||
throw love::Exception("Could not read file %s.", filename.c_str());
|
||||
|
||||
int max = (int)PHYSFS_fileLength(file);
|
||||
size = (size == ALL) ? max : size;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <common/config.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <common/utf8.h>
|
||||
#include <common/b64.h>
|
||||
|
||||
|
||||
@@ -218,7 +218,12 @@ namespace physfs
|
||||
|
||||
int w_load(lua_State * L)
|
||||
{
|
||||
return instance->load(L);
|
||||
try {
|
||||
return instance->load(L);
|
||||
}
|
||||
catch (love::Exception & e) {
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
int w_getLastModified(lua_State * L)
|
||||
|
||||
@@ -165,20 +165,24 @@ namespace opengl
|
||||
|
||||
// Get caption.
|
||||
|
||||
// Special case for fullscreen -> windowed. Windows XP did not
|
||||
// work well with "normal" display mode change in this case.
|
||||
// The application window does leave fullscreen, but the desktop
|
||||
// resolution does not revert to the correct one. Restarting the
|
||||
// SDL video subsystem does the trick, though.
|
||||
if( currentMode.fullscreen && !fullscreen )
|
||||
// We need to restart the subsystem for two reasons:
|
||||
// 1) Special case for fullscreen -> windowed. Windows XP did not
|
||||
// work well with "normal" display mode change in this case.
|
||||
// The application window does leave fullscreen, but the desktop
|
||||
// resolution does not revert to the correct one. Restarting the
|
||||
// SDL video subsystem does the trick, though.
|
||||
// 2) Restart the event system (for whatever reason the event system
|
||||
// started and stopped with SDL_INIT_VIDEO, see:
|
||||
// http://sdl.beuc.net/sdl.wiki/Introduction_to_Events)
|
||||
// because the mouse position will not be able to exceed
|
||||
// the previous' video mode window size (i.e. alway
|
||||
// love.mouse.getX() < 800 when switching from 800x600 to a
|
||||
// higher resolution)
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
// Restart.
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
std::cout << "Could not init SDL_VIDEO: " << SDL_GetError() << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::cout << "Could not init SDL_VIDEO: " << SDL_GetError() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set caption.
|
||||
@@ -299,14 +303,11 @@ namespace opengl
|
||||
bool Graphics::toggleFullscreen()
|
||||
{
|
||||
// Try to do the change.
|
||||
if(!setMode(currentMode.width,
|
||||
return setMode(currentMode.width,
|
||||
currentMode.height,
|
||||
!currentMode.fullscreen,
|
||||
currentMode.vsync,
|
||||
currentMode.fsaa))
|
||||
return false;
|
||||
currentMode.fullscreen = !currentMode.fullscreen;
|
||||
return true;
|
||||
currentMode.fsaa);
|
||||
}
|
||||
|
||||
|
||||
@@ -829,20 +830,20 @@ namespace opengl
|
||||
|
||||
if (args % 2) // an odd number of arguments, no good for a polyline
|
||||
return luaL_error(L, "Number of vertices must be a multiple of two");
|
||||
else if (args < 4)
|
||||
return luaL_error(L, "Need at least two vertices to draw a line");
|
||||
|
||||
// right, let's draw this polyline, then
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
if (table) {
|
||||
lua_pushnil(L);
|
||||
while (true) {
|
||||
if(lua_next(L, 1) == 0) break;
|
||||
GLfloat x = (GLfloat)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1); // pop value
|
||||
if(lua_next(L, 1) == 0) break;
|
||||
GLfloat y = (GLfloat)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1); // pop value
|
||||
glVertex2f(x, y);
|
||||
for (int i = 1; i < args; i += 2) {
|
||||
lua_pushnumber(L, i); // x coordinate
|
||||
lua_rawget(L, 1);
|
||||
lua_pushnumber(L, i+1); // y coordinate
|
||||
lua_rawget(L, 1);
|
||||
glVertex2f((GLfloat)lua_tonumber(L, -2), (GLfloat)lua_tonumber(L, -1));
|
||||
lua_pop(L, 2);
|
||||
}
|
||||
} else {
|
||||
for (int i = 1; i < args; i+=2) {
|
||||
|
||||
@@ -452,7 +452,12 @@ namespace opengl
|
||||
// Convert to Data, if necessary.
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T)) {
|
||||
love::filesystem::File * f = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
Data * d = f->read();
|
||||
Data * d;
|
||||
try {
|
||||
d = f->read();
|
||||
} catch (love::Exception & e) {
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
lua_remove(L, 1); // get rid of the file
|
||||
luax_newtype(L, "Data", DATA_T, (void*)d);
|
||||
lua_insert(L, 1); // put it at the bottom of the stack
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace devil
|
||||
case EncodedImageData::FORMAT_TGA:
|
||||
default: // TGA is the default format
|
||||
headerLen = 18;
|
||||
bpp = 3;
|
||||
bpp = 4;
|
||||
size = h * w * bpp;
|
||||
data = new ILubyte[size + headerLen];
|
||||
// here's the header for the Targa file format.
|
||||
@@ -257,23 +257,12 @@ namespace devil
|
||||
data[14] = h & 255; // least significant byte of height
|
||||
data[15] = h >> 8; // most significant byte of height
|
||||
data[16] = bpp * 8; // bits per pixel
|
||||
data[17] = 0; // descriptor bits
|
||||
data[17] = 0x20; // descriptor bits (flip bits: 0x10 horizontal, 0x20 vertical)
|
||||
// header done. write the pixel data to TGA:
|
||||
data += headerLen;
|
||||
ilCopyPixels(0,0,0,w,h,1,IL_BGR,IL_UNSIGNED_BYTE,data); // convert the pixels to BGR (remember, little-endian) and copy them to data
|
||||
ilCopyPixels(0,0,0,w,h,1,IL_BGRA,IL_UNSIGNED_BYTE,data); // convert the pixels to BGRA (remember, little-endian) and copy them to data
|
||||
|
||||
// It's Targa, so we have to flip the image.
|
||||
row = w * bpp;
|
||||
ILubyte * temp = new ILubyte[row];
|
||||
ILubyte * src = data - row;
|
||||
ILubyte * dst = data + size;
|
||||
for (int i = 0; i < (h >> 1); i++) {
|
||||
memcpy(temp,src+=row,row);
|
||||
memcpy(src,dst-=row,row);
|
||||
memcpy(dst,temp,row);
|
||||
}
|
||||
data -= headerLen;
|
||||
delete [] temp;
|
||||
}
|
||||
return new EncodedImageData(data, f, size + headerLen, freeData);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -197,4 +197,4 @@ namespace keyboard
|
||||
} // keyboard
|
||||
} // love
|
||||
|
||||
#endif // LOVE_KEYBOARD_KEYBOARD_H
|
||||
#endif // LOVE_KEYBOARD_KEYBOARD_H
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -34,14 +34,14 @@ namespace sdl
|
||||
bool Keyboard::isDown(Key key) const
|
||||
{
|
||||
SDLKey k;
|
||||
|
||||
|
||||
if(keys.find(key, k))
|
||||
{
|
||||
{
|
||||
Uint8 * keystate = SDL_GetKeyState(0);
|
||||
return keystate[(unsigned)k] == 1;
|
||||
return keystate[(unsigned)k] == 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Keyboard::setKeyRepeat(int delay, int interval) const
|
||||
@@ -58,7 +58,7 @@ namespace sdl
|
||||
SDL_GetKeyRepeat(&delay, &interval);
|
||||
return delay;
|
||||
}
|
||||
|
||||
|
||||
int Keyboard::getKeyRepeatInterval() const
|
||||
{
|
||||
int delay, interval = 0;
|
||||
@@ -66,7 +66,7 @@ namespace sdl
|
||||
return interval;
|
||||
}
|
||||
|
||||
EnumMap<Keyboard::Key, SDLKey, Keyboard::KEY_MAX_ENUM>::Entry Keyboard::keyEntries[] =
|
||||
EnumMap<Keyboard::Key, SDLKey, Keyboard::KEY_MAX_ENUM>::Entry Keyboard::keyEntries[] =
|
||||
{
|
||||
{ Keyboard::KEY_BACKSPACE, SDLK_BACKSPACE},
|
||||
{ Keyboard::KEY_TAB, SDLK_TAB},
|
||||
|
||||
@@ -37,8 +37,9 @@ namespace box2d
|
||||
def->radius = body->world->scaleDown(def->radius);
|
||||
radius = def->radius;
|
||||
this->localPosition = def->localPosition;
|
||||
|
||||
def->userData = (void*)data;
|
||||
shape = body->body->CreateShape(def);
|
||||
shape->SetUserData((void*)data);
|
||||
}
|
||||
|
||||
CircleShape::~CircleShape()
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
DistanceJoint::DistanceJoint(Body * body1, Body * body2, float x1, float y1, float x2, float y2)
|
||||
: Joint(body1, body2)
|
||||
: Joint(body1, body2), joint(NULL)
|
||||
{
|
||||
b2DistanceJointDef def;
|
||||
def.Initialize(body1->body, body2->body, world->scaleDown(b2Vec2(x1,y1)), world->scaleDown(b2Vec2(x2,y2)));
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
GearJoint::GearJoint(Joint * joint1, Joint * joint2, float ratio)
|
||||
: Joint(joint1->body2, joint2->body2)
|
||||
: Joint(joint1->body2, joint2->body2), joint(NULL)
|
||||
{
|
||||
b2GearJointDef def;
|
||||
def.joint1 = joint1->joint;
|
||||
|
||||
@@ -117,7 +117,8 @@ namespace box2d
|
||||
|
||||
void Joint::destroyJoint(b2Joint * joint)
|
||||
{
|
||||
world->world->DestroyJoint(joint);
|
||||
if (joint != NULL)
|
||||
world->world->DestroyJoint(joint);
|
||||
}
|
||||
|
||||
} // box2d
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
MouseJoint::MouseJoint(Body * body1, float x, float y)
|
||||
: Joint(body1)
|
||||
: Joint(body1), joint(NULL)
|
||||
{
|
||||
b2MouseJointDef def;
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace box2d
|
||||
for(int i = 0; i<def->vertexCount; i++)
|
||||
def->vertices[i] = body->world->scaleDown(def->vertices[i]);
|
||||
|
||||
def->userData = (void*)data;
|
||||
shape = body->body->CreateShape(def);
|
||||
shape->SetUserData((void*)data);
|
||||
}
|
||||
|
||||
PolygonShape::~PolygonShape()
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
PrismaticJoint::PrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay)
|
||||
: Joint(body1, body2)
|
||||
: Joint(body1, body2), joint(NULL)
|
||||
{
|
||||
b2PrismaticJointDef def;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
PulleyJoint::PulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio)
|
||||
: Joint(body1, body2)
|
||||
: Joint(body1, body2), joint(NULL)
|
||||
{
|
||||
b2PulleyJointDef def;
|
||||
def.Initialize(body1->body, body2->body, world->scaleDown(groundAnchor1), world->scaleDown(groundAnchor2), \
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
RevoluteJoint::RevoluteJoint(Body * body1, Body * body2, float x, float y)
|
||||
: Joint(body1, body2)
|
||||
: Joint(body1, body2), joint(NULL)
|
||||
{
|
||||
b2RevoluteJointDef def;
|
||||
def.Initialize(body1->body, body2->body, world->scaleDown(b2Vec2(x,y)));
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
Shape::Shape(Body * body)
|
||||
: body(body)
|
||||
: body(body), shape(NULL)
|
||||
{
|
||||
body->retain();
|
||||
data = new shapeudata();
|
||||
@@ -49,7 +49,8 @@ namespace box2d
|
||||
delete data;
|
||||
data = 0;
|
||||
|
||||
body->body->DestroyShape(shape);
|
||||
if (shape)
|
||||
body->body->DestroyShape(shape);
|
||||
shape = 0;
|
||||
|
||||
body->release();
|
||||
|
||||
@@ -96,14 +96,14 @@ namespace box2d
|
||||
}
|
||||
|
||||
World::World(b2AABB aabb)
|
||||
: meter(DEFAULT_METER)
|
||||
: meter(DEFAULT_METER), world(NULL)
|
||||
{
|
||||
world = new b2World(scaleDown(aabb), b2Vec2(0,0), true);
|
||||
world->SetContactListener(this);
|
||||
}
|
||||
|
||||
World::World(b2AABB aabb, b2Vec2 gravity, bool sleep, int meter)
|
||||
: meter(meter)
|
||||
: meter(meter), world(NULL)
|
||||
{
|
||||
world = new b2World(scaleDown(aabb), scaleDown(gravity), sleep);
|
||||
world->SetContactListener(this);
|
||||
|
||||
@@ -38,7 +38,19 @@ namespace lullaby
|
||||
settings.mBits = 16;
|
||||
settings.mFrequency = sampleRate;
|
||||
settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
|
||||
|
||||
// fill with modplug defaults (modplug _memsets_, so we could get
|
||||
// garbage settings when the struct is only partially initialized)
|
||||
settings.mStereoSeparation = 128;
|
||||
settings.mMaxMixChannels = 32;
|
||||
settings.mReverbDepth = 0;
|
||||
settings.mReverbDelay = 0;
|
||||
settings.mBassAmount = 0;
|
||||
settings.mBassRange = 0;
|
||||
settings.mSurroundDepth = 0;
|
||||
settings.mSurroundDelay = 0;
|
||||
settings.mLoopCount = 0;
|
||||
|
||||
ModPlug_SetSettings(&settings);
|
||||
|
||||
// Load the module.
|
||||
@@ -47,7 +59,8 @@ namespace lullaby
|
||||
if(plug == 0)
|
||||
throw love::Exception("Could not load file with ModPlug.");
|
||||
|
||||
ModPlug_SetMasterVolume(plug, 512);
|
||||
// set master volume for delicate ears
|
||||
ModPlug_SetMasterVolume(plug, 128);
|
||||
}
|
||||
|
||||
ModPlugDecoder::~ModPlugDecoder()
|
||||
@@ -101,7 +114,7 @@ namespace lullaby
|
||||
// Let's reload.
|
||||
ModPlug_Unload(plug);
|
||||
plug = ModPlug_Load(data->getData(), data->getSize());
|
||||
ModPlug_SetMasterVolume(plug, 512);
|
||||
ModPlug_SetMasterVolume(plug, 128);
|
||||
eof = false;
|
||||
return (plug != 0);
|
||||
}
|
||||
|
||||
@@ -77,14 +77,14 @@ namespace sdl
|
||||
Thread *t = luax_checkthread(L, 1);
|
||||
std::string name = luax_checklstring(L, 2);
|
||||
t->lock();
|
||||
ThreadVariant *v = t->get(name);
|
||||
ThreadVariant *v = t->receive(name);
|
||||
t->clear(name);
|
||||
t->unlock();
|
||||
if (!v)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
t->clear(name);
|
||||
t->unlock();
|
||||
switch(v->type)
|
||||
{
|
||||
case BOOLEAN:
|
||||
@@ -123,13 +123,13 @@ namespace sdl
|
||||
std::string name = luax_checklstring(L, 2);
|
||||
t->lock();
|
||||
ThreadVariant *v = t->demand(name);
|
||||
t->clear(name);
|
||||
t->unlock();
|
||||
if (!v)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
t->clear(name);
|
||||
t->unlock();
|
||||
switch(v->type)
|
||||
{
|
||||
case BOOLEAN:
|
||||
@@ -166,7 +166,9 @@ namespace sdl
|
||||
{
|
||||
Thread *t = luax_checkthread(L, 1);
|
||||
std::string name = luax_checklstring(L, 2);
|
||||
ThreadVariant *v = t->get(name);
|
||||
t->lock();
|
||||
ThreadVariant *v = t->receive(name);
|
||||
t->unlock();
|
||||
if (!v)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
@@ -282,7 +284,14 @@ namespace sdl
|
||||
if (lua_isstring(L, 2))
|
||||
luax_convobj(L, 2, "filesystem", "newFile");
|
||||
if (luax_istype(L, 2, FILESYSTEM_FILE_T))
|
||||
data = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T)->read();
|
||||
{
|
||||
Data * d;
|
||||
try {
|
||||
data = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T)->read();
|
||||
} catch (love::Exception & e) {
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
data = luax_checktype<love::Data>(L, 2, "Data", DATA_T);
|
||||
Thread *t = instance->newThread(name, data);
|
||||
@@ -300,12 +309,12 @@ namespace sdl
|
||||
lua_newtable(L);
|
||||
for (unsigned int i = 0; i<count; i++)
|
||||
{
|
||||
// allow names containing \0
|
||||
lua_pushlstring(L, list[i]->getName().c_str(), list[i]->getName().length());
|
||||
luax_newtype(L, "Thread", THREAD_THREAD_T, (void*) list[i]);
|
||||
list[i]->lock();
|
||||
list[i]->retain();
|
||||
list[i]->unlock();
|
||||
// allow names containing \0
|
||||
lua_pushlstring(L, list[i]->getName().c_str(), list[i]->getName().length());
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
delete[] list;
|
||||
|
||||
Reference in New Issue
Block a user