Skip to content

Commit

Permalink
Merge branch 'master' into 3.3.0
Browse files Browse the repository at this point in the history
Also remove FTGL from cmake etc. since it's no longer needed
  • Loading branch information
sirjuddington committed May 28, 2024
2 parents bb8b2ec + 8b20bb0 commit a2aea03
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 59 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ jobs:
}
- {
name: "Linux GCC",
os: ubuntu-20.04,
deps_cmdline: "sudo apt-key adv --fetch-keys https://repos.codelite.org/CodeLite.asc && \
sudo apt-add-repository 'deb https://repos.codelite.org/wx3.2.0/ubuntu/ focal universe' && \
sudo apt update && sudo apt install \
libfluidsynth-dev libfreeimage-dev libftgl-dev libglm-dev libgtk-3-dev \
liblua5.3-dev libmpg123-dev libsfml-dev libwxgtk3.2unofficial-dev"
os: ubuntu-24.04,
deps_cmdline: "sudo apt install \
libfluidsynth-dev libfreeimage-dev libwebkit2gtk-4.1-dev \
libglm-dev libgtk-3-dev liblua5.3-dev libmpg123-dev libsfml-dev \
libwxgtk3.2-dev libwxgtk-webview3.2-dev"
}
- {
name: "Linux Clang",
os: ubuntu-20.04,
os: ubuntu-24.04,
extra_options: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++",
deps_cmdline: "sudo apt-key adv --fetch-keys https://repos.codelite.org/CodeLite.asc && \
sudo apt-add-repository 'deb https://repos.codelite.org/wx3.2.0/ubuntu/ focal universe' && \
sudo apt update && sudo apt install \
libfluidsynth-dev libfreeimage-dev libftgl-dev libglm-dev libgtk-3-dev \
liblua5.3-dev libmpg123-dev libsfml-dev libwxgtk3.2unofficial-dev"
deps_cmdline: "sudo apt install \
libfluidsynth-dev libfreeimage-dev libwebkit2gtk-4.1-dev \
libglm-dev libgtk-3-dev liblua5.3-dev libmpg123-dev libsfml-dev \
libwxgtk3.2-dev libwxgtk-webview3.2-dev"
}

steps:
Expand Down
6 changes: 3 additions & 3 deletions COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* C++17 compiler (e.g. g++ 8.x)
* bzip2 library
* FreeImage
* ftgl, an OpenGL font managing library
* glm
* GTK 2.x/3.x
* mpg123 library
* OpenGL
* SFML
* wxWidgets 3.x
* wxWidgets 3.2+
* zlib

### Optional build-time requirements
Expand All @@ -30,7 +30,7 @@ SLADE can be built on Windows using [Visual Studio](https://visualstudio.microso
### Required vcpkg libraries

* freeimage
* ftgl
* glm
* lua
* mpg123
* opengl
Expand Down
22 changes: 0 additions & 22 deletions cmake/find_modules/FindFTGL.cmake

This file was deleted.

3 changes: 0 additions & 3 deletions cmake/unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ ADD_DEFINITIONS(-DUSE_SFML_RENDERWINDOW)
else (USE_SFML_RENDERWINDOW)
set(SFML_FIND_COMPONENTS system audio window network)
find_package(Freetype REQUIRED)
find_package(FTGL REQUIRED)
endif(USE_SFML_RENDERWINDOW)

# Fluidsynth
Expand Down Expand Up @@ -115,7 +114,6 @@ include_directories(
${FREEIMAGE_INCLUDE_DIR}
${SFML_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIRS}
${FTGL_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${MPG123_INCLUDE_DIR}
.
Expand Down Expand Up @@ -175,7 +173,6 @@ target_link_libraries(slade
${FREEIMAGE_LIBRARIES}
${SFML_LIBRARY}
${FREETYPE_LIBRARIES}
${FTGL_LIBRARIES}
${OPENGL_LIBRARIES}
${LUA_LIBRARIES}
${MPG123_LIBRARIES}
Expand Down
4 changes: 1 addition & 3 deletions cmake/win_msvc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ add_compile_options(/bigobj)
find_package(wxWidgets CONFIG REQUIRED)
set(WX_LIBS wx::core wx::base wx::stc wx::aui wx::gl wx::propgrid wx::net)

# FTGL
# FreeType
find_package(Freetype REQUIRED)
find_package(FTGL REQUIRED)

# Lua
if (NOT NO_LUA)
Expand Down Expand Up @@ -90,7 +89,6 @@ target_link_libraries(slade
${BZIP2_LIBRARIES}
${EXTERNAL_LIBRARIES}
${FREETYPE_LIBRARIES}
${FTGL_LIBRARIES}
${OPENGL_LIBRARIES}
${WX_LIBS}
${ZLIB_LIBRARY}
Expand Down
31 changes: 24 additions & 7 deletions src/Application/SLADEWxApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "Archive/ArchiveManager.h"
#include "General/Console.h"
#include "General/SAction.h"
#include "General/Web.h"
#include "MainEditor/MainEditor.h"
#include "MainEditor/UI/ArchiveManagerPanel.h"
#include "MainEditor/UI/MainWindow.h"
Expand All @@ -48,6 +47,7 @@
#include <wx/filefn.h>
#include <wx/statbmp.h>
#include <wx/url.h>
#include <wx/webrequest.h>
#undef BOOL
#ifdef UPDATEREVISION
#include "gitinfo.h"
Expand Down Expand Up @@ -510,8 +510,9 @@ bool SLADEWxApp::OnInit()

// Bind events
Bind(wxEVT_MENU, &SLADEWxApp::onMenu, this);
Bind(wxEVT_THREAD_WEBGET_COMPLETED, &SLADEWxApp::onVersionCheckCompleted, this);
Bind(wxEVT_WEBREQUEST_STATE, &SLADEWxApp::onVersionCheckCompleted, this);
Bind(wxEVT_ACTIVATE_APP, &SLADEWxApp::onActivate, this);
Bind(wxEVT_QUERY_END_SESSION, &SLADEWxApp::onEndSession, this);

return true;
}
Expand Down Expand Up @@ -560,7 +561,8 @@ void SLADEWxApp::checkForUpdates(bool message_box)
#ifdef __WXMSW__
update_check_message_box = message_box;
log::info(1, "Checking for updates...");
web::getHttpAsync("slade.mancubus.net", "/version_win.txt", this);
auto request = wxWebSession::GetDefault().CreateRequest(this, "https://slade.mancubus.net/version_win.txt");
request.Start();
#endif
}

Expand Down Expand Up @@ -611,10 +613,10 @@ void SLADEWxApp::onMenu(wxCommandEvent& e)
// -----------------------------------------------------------------------------
// Called when the version check thread completes
// -----------------------------------------------------------------------------
void SLADEWxApp::onVersionCheckCompleted(wxThreadEvent& e)
void SLADEWxApp::onVersionCheckCompleted(wxWebRequestEvent& e)
{
// Check failed
if (e.GetString() == "connect_failed")
if (e.GetState() == wxWebRequest::State_Failed || e.GetState() == wxWebRequest::State_Unauthorized)
{
log::error("Version check failed, unable to connect");
if (update_check_message_box)
Expand All @@ -626,11 +628,16 @@ void SLADEWxApp::onVersionCheckCompleted(wxThreadEvent& e)
return;
}

// If not completed, ignore
if (e.GetState() != wxWebRequest::State_Completed)
return;

// Parse version info
app::Version stable, beta;
string bin_stable, installer_stable, bin_beta; // Currently unused but may be useful in the future
Parser parser;
if (parser.parseText(e.GetString().ToStdString()))
auto response_string = e.GetResponse().AsString();
if (parser.parseText(response_string.ToStdString()))
{
// Stable
if (auto node_stable = parser.parseTreeRoot()->childPTN("stable"))
Expand Down Expand Up @@ -677,7 +684,7 @@ void SLADEWxApp::onVersionCheckCompleted(wxThreadEvent& e)
if (stable.major == 0 || beta.major == 0)
{
log::warning("Version check failed, received invalid version info");
log::debug("Received version text:\n\n%s", wxutil::strToView(e.GetString()));
log::debug("Received version text:\n\n%s", wxutil::strToView(response_string));
if (update_check_message_box)
wxMessageBox("Update check failed: received invalid version info.", "Check for Updates");
return;
Expand Down Expand Up @@ -745,6 +752,16 @@ void SLADEWxApp::onActivate(wxActivateEvent& e)
e.Skip();
}

// -----------------------------------------------------------------------------
// Called when the system is ending the session (shutdown/restart)
// -----------------------------------------------------------------------------
void SLADEWxApp::onEndSession(wxCloseEvent& e)
{
session_ending_ = true;
maineditor::windowWx()->Close();
e.Skip();
}


// -----------------------------------------------------------------------------
//
Expand Down
9 changes: 7 additions & 2 deletions src/Application/SLADEWxApp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

class wxWebRequestEvent;
class wxSingleInstanceChecker;
class MainAppFileListener;
class SLADECrashDialog;
Expand All @@ -10,6 +11,8 @@ class SLADEWxApp : public wxApp
SLADEWxApp() = default;
~SLADEWxApp() override = default;

bool isSessionEnding() const { return session_ending_; }

bool OnInit() override;
int OnExit() override;
void OnFatalException() override;
Expand All @@ -22,13 +25,15 @@ class SLADEWxApp : public wxApp
void checkForUpdates(bool message_box);

void onMenu(wxCommandEvent& e);
void onVersionCheckCompleted(wxThreadEvent& e);
void onActivate(wxActivateEvent& event);
void onVersionCheckCompleted(wxWebRequestEvent& e);
void onActivate(wxActivateEvent& e);
void onEndSession(wxCloseEvent& e);

private:
wxSingleInstanceChecker* single_instance_checker_ = nullptr;
MainAppFileListener* file_listener_ = nullptr;
SLADECrashDialog* crash_dialog_ = nullptr;
bool session_ending_ = false;
};

DECLARE_APP(SLADEWxApp)
2 changes: 1 addition & 1 deletion src/Graphics/SImage/Formats/SIFImages.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class SIFPng : public SIFormat
if (usepal.transIndex() < 0)
{
// Find unused colour (for transparency)
short unused = image.findUnusedColour();
short unused = image.findUnusedColour(255);

// Set any transparent pixels to this colour (if we found an unused colour)
bool has_trans = false;
Expand Down
8 changes: 7 additions & 1 deletion src/Graphics/SImage/SImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,10 @@ void SImage::fillAlpha(uint8_t alpha)
// -----------------------------------------------------------------------------
// Returns the first unused palette index, or -1 if the image is not paletted or
// uses all 256 colours
// If [preferred] is > 0, it will be returned if it's not already in use,
// instead of the first unused colour
// -----------------------------------------------------------------------------
short SImage::findUnusedColour() const
short SImage::findUnusedColour(short preferred) const
{
// Only for paletted images
if (type_ != Type::PalMask)
Expand All @@ -560,6 +562,10 @@ short SImage::findUnusedColour() const
for (int a = 0; a < width_ * height_; a++)
used[data_[a]] = 1;

// Check if preferred colour is unused
if (preferred >= 0 && !used[preferred])
return preferred;

// Find first unused
for (int a = 0; a < 256; a++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/SImage/SImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class SImage
void create(int width, int height, Type type, const Palette* pal = nullptr, int index = 0, int numimages = 1);
void create(const Info& info, const Palette* pal = nullptr);
void fillAlpha(uint8_t alpha = 0);
short findUnusedColour() const;
short findUnusedColour(short preferred = -1) const;
size_t countColours() const;
void shrinkPalette(Palette* pal = nullptr) const;
bool copyImage(const SImage* image);
Expand Down
10 changes: 10 additions & 0 deletions src/MainEditor/EntryOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,16 @@ bool entryoperations::sortEntries(
if (entry->type() == EntryType::folderType())
continue;

// If not a WAD, do basic alphabetical sorting
if (archive.formatId() != "wad" && archive.formatId() != "wadj")
{
auto sortkey = wxString::Format("%-64s%8d", entry->upperName(), indices[i]);
emap[sortkey] = indices[i];
entry->exProp("sortkey") = sortkey.ToStdString();

continue;
}

// If this is a map entry, deal with it
if (!maps.empty() && mapindex > -1)
{
Expand Down
2 changes: 1 addition & 1 deletion src/MainEditor/UI/ArchivePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ bool ArchivePanel::importEntry()
}

// Prompt to update entry extensions
if (entry_type_changed && archive_.lock()->formatDesc().names_extensions)
if (entry_type_changed && archive_.lock()->formatInfo().names_extensions)
{
auto multi_select = selection.size() > 1;

Expand Down
2 changes: 1 addition & 1 deletion src/MainEditor/UI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ void MainWindow::setupLayout()
bool MainWindow::exitProgram()
{
// Confirm exit
if (confirm_exit && !panel_archivemanager_->askedSaveUnchanged())
if (!wxGetApp().isSessionEnding() && confirm_exit && !panel_archivemanager_->askedSaveUnchanged())
{
if (wxMessageBox("Are you sure you want to exit SLADE?", "SLADE", wxICON_QUESTION | wxYES_NO, this) != wxYES)
return false;
Expand Down
4 changes: 4 additions & 0 deletions src/MainEditor/UI/TextureXEditor/TextureEditorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ void TextureEditorPanel::setupLayout()
// Add texture canvas
vbox->Add(tex_canvas_->window(), wxSizerFlags(1).Expand());

// Apply texture canvas options
tex_canvas_->applyTexScale(tx_apply_scale);
tex_canvas_->drawOutside(tx_show_outside);

// Add extra view controls
hbox = new wxBoxSizer(wxHORIZONTAL);
vbox->Add(hbox, wx::sfWithBorder(0, wxBOTTOM | wxTOP).Expand());
Expand Down
2 changes: 1 addition & 1 deletion src/MapEditor/UI/ActionSpecialPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ wxDataViewItem ActionSpecialTreeView::getGroup(const wxString& group_name)

if (!found)
{
current = AppendContainer(current, path[p], -1, 1);
current = AppendContainer(current, path[p]);
groups_.emplace_back(current, fullpath);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/MapEditor/UI/MapEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ bool MapEditorWindow::handleAction(string_view id)
{
p_inf.Show(true);
p_inf.window->SetFocus();
dynamic_cast<ConsolePanel*>(p_inf.window)->focusInput();
}

p_inf.MinSize(wxutil::scaledSize(200, 128));
Expand Down
1 change: 1 addition & 0 deletions src/Scripting/UI/ScriptManagerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ bool ScriptManagerWindow::handleAction(string_view id)
auto& p_inf = m_mgr->GetPane("console");
p_inf.Show(!p_inf.IsShown());
p_inf.MinSize(200, 128);
dynamic_cast<ConsolePanel*>(p_inf.window)->focusInput();
m_mgr->Update();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/UI/WxUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ wxPanel* wxutil::createPadPanel(wxWindow* parent, wxWindow* control, int pad)

auto panel = new wxPanel(parent);
panel->SetSizer(new wxBoxSizer(wxVERTICAL));
panel->GetSizer()->Add(control, 1, wxEXPAND | wxALL, pad);
control->Reparent(panel);
panel->GetSizer()->Add(control, 1, wxEXPAND | wxALL, pad);

return panel;
}
Expand Down

0 comments on commit a2aea03

Please sign in to comment.