Skip to content

Commit

Permalink
Merge pull request #74 from fallahn/golf-1.12
Browse files Browse the repository at this point in the history
Golf 1.12.2
  • Loading branch information
fallahn authored Apr 30, 2023
2 parents 57ca785 + 8be7010 commit dabf540
Show file tree
Hide file tree
Showing 27 changed files with 373 additions and 123 deletions.
6 changes: 6 additions & 0 deletions crogine/include/crogine/audio/AudioScape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ namespace cro
*/
bool hasEmitter(const std::string& name) const;

/*!
\brief Returns the name from which this AudioScape was loaded, or an empty string
*/
const std::string& getName() const { return m_name; }

private:
AudioResource* m_audioResource;
std::string m_name;

struct AudioConfig final
{
Expand Down
7 changes: 7 additions & 0 deletions crogine/include/crogine/graphics/ModelDefinition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ namespace cro
*/
bool hasSkeleton() const { return m_skeleton; }

/*!
\brief Return a copy of the Skeleton component
Check if the component is valid (models may not always load a skeleton)
with hasSkeleton()
*/
const Skeleton& getSkeleton() const { return m_skeleton; }

/*!
\brief Returns the assigned material at the given index, if it exists
else returns nullptr
Expand Down
2 changes: 1 addition & 1 deletion crogine/include/crogine/util/Rectangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace cro
cro::Rectangle<T> ret(std::min(a.left, b.left),
std::min(a.bottom, b.bottom),
std::max(a.left + a.width, b.left + b.width),
std::max(a.botom + a.height, b.bottom + b.height));
std::max(a.bottom + a.height, b.bottom + b.height));
ret.width -= ret.left;
ret.height -= ret.bottom;

Expand Down
2 changes: 2 additions & 0 deletions crogine/src/audio/AudioScape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ bool AudioScape::loadFromFile(const std::string& path, AudioResource& audioResou
{
m_audioResource = &audioResource;
m_configs.clear();
m_name.clear();

const auto& objs = cfg.getObjects();
for (const auto& obj : objs)
Expand Down Expand Up @@ -130,6 +131,7 @@ bool AudioScape::loadFromFile(const std::string& path, AudioResource& audioResou
LogW << "No valid AudioScape definitions were loaded from " << path << std::endl;
return false;
}
m_name = cro::FileSystem::getFileName(path);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion crogine/src/core/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void winAbort(int)
#include <algorithm>

#ifdef CRO_DEBUG_
//#define DEBUG_NO_CONTROLLER
#define DEBUG_NO_CONTROLLER
#endif // CRO_DEBUG_

using namespace cro;
Expand Down
2 changes: 1 addition & 1 deletion crogine/src/ecs/components/Drawable2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void Drawable2D::applyShader()
else
{
m_textureUniform = -1;
Logger::log("Missing texture uniform in Drawable2D shader", Logger::Type::Error);
Logger::log("Missing texture uniform in Drawable2D shader", Logger::Type::Warning);
return;
}
}
Expand Down
40 changes: 37 additions & 3 deletions crogine/src/graphics/ImageArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,20 @@ namespace cro::Detail
stbi_callback_from_RW(file, &io);

std::int32_t w, h, d;
auto* img = stbi_load_from_callbacks(&io.stb_cbs, &io, &w, &h, &d, 0);
stbi_info_from_callbacks(&io.stb_cbs, &io, &w, &h, &d);
file->seek(file, 0, RW_SEEK_SET);

//if this is RGB pad out to RGBA for row alignment
std::int32_t wantedChannels = 0;
if (d == 3)
{
wantedChannels = 4;
}

auto* img = stbi_load_from_callbacks(&io.stb_cbs, &io, &w, &h, &d, wantedChannels);
if (img)
{
d = (wantedChannels) ? wantedChannels : d;
auto size = w * h * d;

dst.resize(size);
Expand Down Expand Up @@ -95,9 +106,21 @@ namespace cro::Detail
stbi_callback_from_RW(file, &io);

std::int32_t w, h, d;
auto* img = stbi_load_16_from_callbacks(&io.stb_cbs, &io, &w, &h, &d, 0);
stbi_info_from_callbacks(&io.stb_cbs, &io, &w, &h, &d);
file->seek(file, 0, RW_SEEK_SET);

//if this is RGB pad out to RGBA for row alignment
std::int32_t wantedChannels = 0;
if (d == 3)
{
wantedChannels = 4;
}


auto* img = stbi_load_16_from_callbacks(&io.stb_cbs, &io, &w, &h, &d, wantedChannels);
if (img)
{
d = (wantedChannels) ? wantedChannels : d;
auto size = w * h * d;

dst.resize(size);
Expand Down Expand Up @@ -137,9 +160,20 @@ namespace cro::Detail
stbi_callback_from_RW(file, &io);

std::int32_t w, h, d;
auto* img = stbi_loadf_from_callbacks(&io.stb_cbs, &io, &w, &h, &d, 0);
stbi_info_from_callbacks(&io.stb_cbs, &io, &w, &h, &d);
file->seek(file, 0, RW_SEEK_SET);

//if this is RGB pad out to RGBA for row alignment
std::int32_t wantedChannels = 0;
if (d == 3)
{
wantedChannels = 4;
}

auto* img = stbi_loadf_from_callbacks(&io.stb_cbs, &io, &w, &h, &d, wantedChannels);
if (img)
{
d = (wantedChannels) ? wantedChannels : 0;
auto size = w * h * d;

dst.resize(size);
Expand Down
11 changes: 8 additions & 3 deletions crogine/src/graphics/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void Texture::create(std::uint32_t width, std::uint32_t height, ImageFormat::Typ
pixelSize = 1;
}


//let's fill the texture with known empty values
std::vector<std::uint8_t> buffer(width * height * pixelSize);
std::fill(buffer.begin(), buffer.end(), 0);
Expand All @@ -187,7 +188,10 @@ bool Texture::loadFromFile(const std::string& filePath, bool createMipMaps)
ImageArray<std::uint8_t> arr;
if (arr.loadFromFile(path, true))
{
m_type = GL_UNSIGNED_BYTE;

auto size = arr.getDimensions();
CRO_ASSERT(size.x * size.y * arr.getChannels() == arr.size(), "");
create(size.x, size.y, arr.getFormat());
return update(arr.data(), createMipMaps);
}
Expand Down Expand Up @@ -470,16 +474,17 @@ bool Texture::update(const void* pixels, bool createMipMaps, URect area)
if (area.width == 0) area.width = m_size.x;
if (area.height == 0) area.height = m_size.y;

GLint format = GL_RGBA;
if (m_format == ImageFormat::RGB)
GLint format = GL_RGB;
if (m_format == ImageFormat::RGBA)
{
format = GL_RGB;
format = GL_RGBA;
}
else if (m_format == ImageFormat::A)
{
format = GL_RED;
}


glCheck(glBindTexture(GL_TEXTURE_2D, m_handle));
glCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, area.left, area.bottom, area.width, area.height, format, m_type, pixels));

Expand Down
5 changes: 3 additions & 2 deletions libsocial/include/Social.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ source distribution.
//(terrain vertex data and materials changed 1100 -> 1110)
//(player avatar data format changed 1110 -> 1120)
static constexpr std::uint16_t CURRENT_VER = 1120;
static const std::string StringVer("1.12.1");
static const std::string StringVer("1.12.2");


class Social final
Expand Down Expand Up @@ -74,6 +74,7 @@ class Social final
{
enum
{
AvatarDownloaded,
LevelUp,
XPAwarded,
OverlayActivated,
Expand Down Expand Up @@ -134,7 +135,7 @@ class Social final
enum
{
Ball, Hair, Course,
Profile
Profile, Avatar
};
};
static std::string getBaseContentPath();
Expand Down
2 changes: 2 additions & 0 deletions libsocial/src/Social.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,5 +411,7 @@ std::string Social::getUserContentPath(std::int32_t contentType)
return getBaseContentPath() + "hair/";
case Social::UserContent::Profile:
return getBaseContentPath() + "profiles/";
case Social::UserContent::Avatar:
return getBaseContentPath() + "avatars/";
}
}
Binary file modified samples/golf/golf.aps
Binary file not shown.
8 changes: 4 additions & 4 deletions samples/golf/golf.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ IDI_ICON1 ICON "icon.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,12,0,0
PRODUCTVERSION 1,12,0,0
FILEVERSION 1,12,2,0
PRODUCTVERSION 1,12,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Trederia"
VALUE "FileDescription", "Super Video Golf"
VALUE "FileVersion", "1.12.0.0"
VALUE "FileVersion", "1.12.2.0"
VALUE "InternalName", "golf.exe"
VALUE "LegalCopyright", "Copyright (C) 2023 Trederia Games"
VALUE "OriginalFilename", "golf.exe"
VALUE "ProductName", "Super Video Golf"
VALUE "ProductVersion", "1.12.0.0"
VALUE "ProductVersion", "1.12.2.0"
END
END
BLOCK "VarFileInfo"
Expand Down
Binary file modified samples/golf/mod_kit/avatar_keys.ase
Binary file not shown.
2 changes: 1 addition & 1 deletion samples/golf/src/GolfGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ bool GolfGame::initialise()
cro::Logger::log("No suitable host addresses were found", cro::Logger::Type::Error, cro::Logger::Output::All);
return false;
}
Social::userIcon = cropAvatarImage("assets/workshop/profile_template.png");
Social::userIcon = cropAvatarImage("assets/images/default_profile.png");
#endif

parseCredits();
Expand Down
8 changes: 8 additions & 0 deletions samples/golf/src/golf/GameConsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ static inline constexpr float smoothstep(float edge0, float edge1, float x)
return t * t * (3.f - 2.f * t);
}

static inline cro::FloatRect getAvatarBounds(std::uint8_t player)
{
cro::FloatRect bounds = { 0.f, LabelTextureSize.y - (LabelIconSize.x * 4.f), LabelIconSize.x, LabelIconSize.y };
bounds.left = LabelIconSize.x * (player % 2);
bounds.bottom += LabelIconSize.y * (player / 2);
return bounds;
}

static inline cro::Image cropAvatarImage(const std::string& path)
{
cro::ImageArray<std::uint8_t> arr;
Expand Down
Loading

0 comments on commit dabf540

Please sign in to comment.