Tibor 11 months ago
commit 6bc7d02145
  1. 73
      .gitignore
  2. BIN
      icon.ico
  3. 75
      main.cpp
  4. 15
      mainwindow.cpp
  5. 21
      mainwindow.h
  6. 63
      mainwindow.ui
  7. 32
      wdef-importer.pro
  8. 3
      wdef-importer_en_US.ts

73
.gitignore vendored

@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

@ -0,0 +1,75 @@
#include "mainwindow.h"
#include <QApplication>
#include <QOperatingSystemVersion>
#include <QSettings>
#include <QMessageBox>
#include <QFileDialog>
#include <filesystem>
#include <vector>
#include <string>
#include <iostream>
namespace fs = std::filesystem;
fs::path askGiantsDirectory()
{
QMessageBox::information(
nullptr,
"wdefs",
"Could not locate your Giants installation automatically.\nPlease browse to your Giants folder and select GiantsMain.exe."
);
QString filename { QFileDialog::getOpenFileName(nullptr, "wdefs", "C:\\", "GiantsMain.exe") };
if (!filename.isEmpty()) {
return fs::path(filename.toStdString()).parent_path();
}
return fs::path();
}
fs::path locateGiantsFolder()
{
if (QOperatingSystemVersion::Windows == QOperatingSystemVersion::currentType()) {
std::vector<std::string> possiblePaths {
"C:\\Program Files (x86)\\GOG Galaxy\\Games\\Giants - Citizen Kabuto",
"C:\\Program Files\\GOG Galaxy\\Games\\Giants - Citizen Kabuto",
"C:\\Program Files (x86)\\GOG.com\\Games\\Giants - Citizen Kabuto",
"C:\\Program Files\\GOG.com\\Games\\Giants - Citizen Kabuto",
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Giants Citizen Kabuto",
"C:\\Program Files\\Steam\\steamapps\\common\\Giants Citizen Kabuto",
// "D:\\Games\\Giants - Citizen Kabuto"
};
for (auto& path : possiblePaths) {
if (fs::exists(path.append("\\GiantsMain.exe"))) {
return fs::path(path);
}
}
QSettings reg {"HKEY_CURRENT_USER\\Software\\PlanetMoon\\Giants", QSettings::NativeFormat };
QString regPath { reg.value("DestDir", QString()).toString().replace("\\", "\\\\") };
std::string fullPath { regPath.append("\\GiantsMain.exe").toStdString() };
if (fs::exists(fullPath)) {
return fs::path(fullPath);
}
}
return askGiantsDirectory();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
fs::path folder = locateGiantsFolder();
return a.exec();
}

@ -0,0 +1,15 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}

@ -0,0 +1,21 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>548</width>
<height>105</height>
</rect>
</property>
<property name="windowTitle">
<string>Giants wdefs importer</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>531</width>
<height>63</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Play</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>URL to wdefs file</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>548</width>
<height>21</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,32 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
TRANSLATIONS += \
wdef-importer_en_US.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES += \
icon.ico
RC_ICONS = icon.ico

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US"></TS>
Loading…
Cancel
Save