Compare commits

..

10 Commits

30 changed files with 1050 additions and 826 deletions

63
.gitattributes vendored
View File

@@ -1,63 +0,0 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

405
.gitignore vendored
View File

@@ -1,363 +1,60 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# ---> C++
# Prerequisites
*.d
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
# Compiled Object files
*.slo
*.lo
*.o
*.obj
*.iobj
# Precompiled Headers
*.gch
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# ---> Java
# Compiled class file
*.class
# Log file
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# BlueJ files
*.ctxt
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# Visual Studio Trace Files
*.e2e
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -1,21 +1,43 @@
# CMakeList.txt: проект CMake для minecraft-launcher; включите исходный код и определения,
# укажите здесь логику для конкретного проекта.
#
cmake_minimum_required (VERSION 3.8)
cmake_minimum_required(VERSION 3.19)
project(minecraft-launcher LANGUAGES CXX)
# Включение горячей перезагрузки для компиляторов MSVC, если поддерживается.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets)
project ("minecraft-launcher")
qt_standard_project_setup()
# Добавьте источник в исполняемый файл этого проекта.
add_executable (minecraft-launcher "minecraft-launcher.cpp" "minecraft-launcher.h")
qt_add_executable(minecraft-launcher
WIN32 MACOSX_BUNDLE
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET minecraft-launcher PROPERTY CXX_STANDARD 20)
endif()
# TODO: Добавьте тесты и целевые объекты, если это необходимо.
main.cpp
mainwindow.h mainwindow.cpp
settingsdialog.h settingsdialog.cpp
settingsdialog.ui
mainwindow.ui
)
target_link_libraries(minecraft-launcher
PRIVATE
Qt::Core
Qt::Widgets
)
include(GNUInstallDirs)
install(TARGETS minecraft-launcher
BUNDLE DESTINATION .
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
qt_generate_deploy_app_script(
TARGET minecraft-launcher
OUTPUT_SCRIPT deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})

View File

@@ -1,101 +0,0 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-release",
"displayName": "x86 Release",
"inherits": "x86-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "Linux Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
},
{
"name": "macos-debug",
"displayName": "macOS Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
}
]
}

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 70 40">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #637a10;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<path class="cls-2" d="m67.66,40H2.34c-1.29,0-2.34-1.05-2.34-2.36V2.36C0,1.05,1.05,0,2.34,0h65.32c1.29,0,2.34,1.05,2.34,2.36v35.29c0,1.3-1.05,2.36-2.34,2.36Z"/>
<path class="cls-1" d="m40.18,9.72c-2.6,0-4.9,1.28-6.32,3.25h-10.36c-.97,0-1.75.79-1.75,1.76v13.8c0,.97.78,1.76,1.75,1.76h23c.97,0,1.75-.79,1.75-1.76V11.48c0-.97-.78-1.76-1.75-1.76h-6.32Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 743 B

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 70 40">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #232323;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<path class="cls-2" d="m67.66,40H2.34c-1.29,0-2.34-1.05-2.34-2.36V2.36C0,1.05,1.05,0,2.34,0h65.32c1.29,0,2.34,1.05,2.34,2.36v35.29c0,1.3-1.05,2.36-2.34,2.36Z"/>
<path class="cls-1" d="m40.18,9.72c-2.6,0-4.9,1.28-6.32,3.25h-10.36c-.97,0-1.75.79-1.75,1.76v13.8c0,.97.78,1.76,1.75,1.76h23c.97,0,1.75-.79,1.75-1.76V11.48c0-.97-.78-1.76-1.75-1.76h-6.32Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 743 B

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 70 40">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #232323;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<path class="cls-1" d="m67.66,40H2.34c-1.29,0-2.34-1.05-2.34-2.36V2.36C0,1.05,1.05,0,2.34,0h65.32c1.29,0,2.34,1.05,2.34,2.36v35.29c0,1.3-1.05,2.36-2.34,2.36Z"/>
<path class="cls-2" d="m40.18,9.72c-2.6,0-4.9,1.28-6.32,3.25h-10.36c-.97,0-1.75.79-1.75,1.76v13.8c0,.97.78,1.76,1.75,1.76h23c.97,0,1.75-.79,1.75-1.76V11.48c0-.97-.78-1.76-1.75-1.76h-6.32Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 743 B

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 69.88 39.72">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #232323;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-2" width="69.88" height="39.72" rx="2.34" ry="2.34"/>
<g>
<path class="cls-1" d="m46.69,9.71h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
<path class="cls-1" d="m46.69,18.01h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
<path class="cls-1" d="m46.69,26.32h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 978 B

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 69.88 39.72">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #637a10;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-2" width="69.88" height="39.72" rx="2.34" ry="2.34"/>
<g>
<path class="cls-1" d="m46.69,9.71h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
<path class="cls-1" d="m46.69,18.01h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
<path class="cls-1" d="m46.69,26.32h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 978 B

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 69.88 39.72">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #232323;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="69.88" height="39.72" rx="2.34" ry="2.34"/>
<g>
<path class="cls-2" d="m46.69,9.71h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
<path class="cls-2" d="m46.69,18.01h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
<path class="cls-2" d="m46.69,26.32h-23.51c-1.03,0-1.87.83-1.87,1.85h0c0,1.02.84,1.85,1.87,1.85h23.51c1.03,0,1.87-.83,1.87-1.85h0c0-1.02-.84-1.85-1.87-1.85Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 978 B

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 335 170">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #637a10;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-2" width="335" height="170" rx="10.7" ry="10.7"/>
<g>
<path class="cls-1" d="m72.38,98.02v26.54h-24.73V39.35h49.34c5.87,0,9.94,4.38,9.94,10.59v37.37c0,6.21-4.06,10.71-9.94,10.71h-24.62Zm0-21.3h9.82v-15.95h-9.82v15.95Z"/>
<path class="cls-1" d="m114.83,39.35h24.62v63.91h24.84v21.3h-49.46V39.35Z"/>
<path class="cls-1" d="m219.84,39.35l11.07,74.62v10.59h-24.73l-1.47-17.16h-10.84l-1.58,17.16h-24.62v-10.59l11.07-74.62h41.1Zm-16.94,46.75l-2.26-25.32h-2.71l-2.26,25.32h7.23Z"/>
<path class="cls-1" d="m227.51,49.94v-10.59h24.73l5.98,33.11h1.81l6.1-33.11h24.62v10.59l-19.31,51.37v23.25h-24.62v-23.25l-19.31-51.37Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 335 170">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #91b315;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-2" width="335" height="170" rx="10.7" ry="10.7"/>
<g>
<path class="cls-1" d="m72.38,98.02v26.54h-24.73V39.35h49.34c5.87,0,9.94,4.38,9.94,10.59v37.37c0,6.21-4.06,10.71-9.94,10.71h-24.62Zm0-21.3h9.82v-15.95h-9.82v15.95Z"/>
<path class="cls-1" d="m114.83,39.35h24.62v63.91h24.84v21.3h-49.46V39.35Z"/>
<path class="cls-1" d="m219.84,39.35l11.07,74.62v10.59h-24.73l-1.47-17.16h-10.84l-1.58,17.16h-24.62v-10.59l11.07-74.62h41.1Zm-16.94,46.75l-2.26-25.32h-2.71l-2.26,25.32h7.23Z"/>
<path class="cls-1" d="m227.51,49.94v-10.59h24.73l5.98,33.11h1.81l6.1-33.11h24.62v10.59l-19.31,51.37v23.25h-24.62v-23.25l-19.31-51.37Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 335 170">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #91b315;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="335" height="170" rx="10.7" ry="10.7"/>
<g>
<path class="cls-2" d="m72.38,98.02v26.54h-24.73V39.35h49.34c5.87,0,9.94,4.38,9.94,10.59v37.37c0,6.21-4.06,10.71-9.94,10.71h-24.62Zm0-21.3h9.82v-15.95h-9.82v15.95Z"/>
<path class="cls-2" d="m114.83,39.35h24.62v63.91h24.84v21.3h-49.46V39.35Z"/>
<path class="cls-2" d="m219.84,39.35l11.07,74.62v10.59h-24.73l-1.47-17.16h-10.84l-1.58,17.16h-24.62v-10.59l11.07-74.62h41.1Zm-16.94,46.75l-2.26-25.32h-2.71l-2.26,25.32h7.23Z"/>
<path class="cls-2" d="m227.51,49.94v-10.59h24.73l5.98,33.11h1.81l6.1-33.11h24.62v10.59l-19.31,51.37v23.25h-24.62v-23.25l-19.31-51.37Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 118.83 45">
<defs>
<style>
.cls-1 {
fill: #637a10;
stroke-width: 0px;
}
.cls-2 {
fill: none;
stroke: #e6e6e6;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.18px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="118.83" height="45" rx="5.27" ry="5.27"/>
<polyline class="cls-2" points="15.36 24.93 20.41 20.07 25.47 24.93"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 618 B

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 118.83 45">
<defs>
<style>
.cls-1 {
fill: #232323;
stroke-width: 0px;
}
.cls-2 {
fill: none;
stroke: #e6e6e6;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.18px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="118.83" height="45" rx="5.27" ry="5.27"/>
<polyline class="cls-2" points="15.36 24.93 20.41 20.07 25.47 24.93"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 618 B

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 118.83 45">
<defs>
<style>
.cls-1 {
fill: #232323;
stroke-width: 0px;
}
.cls-2 {
fill: none;
stroke: #e6e6e6;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.18px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="118.83" height="45" rx="5.27" ry="5.27"/>
<polyline class="cls-2" points="15.36 20.07 20.41 24.93 25.47 20.07"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 618 B

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3.41 39.95">
<defs>
<style>
.cls-1 {
fill: #e6e6e6;
stroke-width: 0px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" x="0" y="0" width="3.41" height="39.95" rx="1.56" ry="1.56"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 395 B

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3.41 161.66">
<defs>
<style>
.cls-1 {
fill: #637a10;
stroke-width: 0px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" x="0" y="0" width="3.41" height="161.66" rx="1.56" ry="1.56"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 397 B

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 210 45">
<defs>
<style>
.cls-1 {
fill: #232323;
stroke-width: 0px;
}
.cls-2 {
fill: none;
stroke: #e6e6e6;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.18px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="210" height="45" rx="5.24" ry="5.24"/>
<polyline class="cls-2" points="16.58 20.07 21.63 24.93 26.69 20.07"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 612 B

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 210 45">
<defs>
<style>
.cls-1 {
fill: #637a10;
stroke-width: 0px;
}
.cls-2 {
fill: none;
stroke: #e6e6e6;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.18px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="210" height="45" rx="5.24" ry="5.24"/>
<polyline class="cls-2" points="16.58 24.93 21.63 20.07 26.69 24.93"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 612 B

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 210 45">
<defs>
<style>
.cls-1 {
fill: #232323;
stroke-width: 0px;
}
.cls-2 {
fill: none;
stroke: #e6e6e6;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.18px;
}
</style>
</defs>
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" width="210" height="45" rx="5.24" ry="5.24"/>
<polyline class="cls-2" points="16.58 24.93 21.63 20.07 26.69 24.93"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 612 B

10
main.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

323
mainwindow.cpp Normal file
View File

@@ -0,0 +1,323 @@
#include "mainwindow.h"
#include "ui_mainwindow.h" // Подключаем сгенерированный заголовочный файл
#include "settingsdialog.h"
#include <QMessageBox>
#include <QDesktopServices>
#include <QUrl>
#include <QDir>
#include <QInputDialog> // Для диалога выбора
#include <QFileInfo> // Для проверки файла
#include <QJsonDocument> // Для работы с JSON
#include <QJsonObject> // Для работы с JSON
#include <QJsonArray> // Для работы с JSON
#include <QJsonValue> // Для работы с JSON
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow) // Инициализируем указатель на UI
{
ui->setupUi(this); // Загружаем интерфейс из .ui файла
// Начальная настройка виджетов
ui->progressBar->setRange(0, 0); // Неопределенный прогресс-бар
ui->progressBar->setVisible(false);
// Инициализация логики
settings = new QSettings("GaleonDev", "MinecraftLauncher", this);
process = new QProcess(this);
// Подключаем сигналы от процесса (это делается вручную)
connect(process, &QProcess::readyReadStandardOutput, this, &MainWindow::readProcessOutput);
connect(process, &QProcess::readyReadStandardError, this, &MainWindow::readProcessOutput);
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onProcessFinished(int, QProcess::ExitStatus)));
connect(process, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(onProcessError(QProcess::ProcessError)));
}
MainWindow::~MainWindow()
{
delete ui; // Освобождаем память от объекта UI
}
// Вспомогательная функция для проверки правил OS
bool checkRules(const QJsonObject &item) {
if (!item.contains("rules")) {
return true; // Нет правил - разрешено для всех.
}
// Если правила есть, по умолчанию запрещаем, пока не найдем разрешающее правило.
bool isAllowed = false;
QString currentOs;
#if defined(Q_OS_WIN)
currentOs = "windows";
#elif defined(Q_OS_MAC)
currentOs = "osx";
#elif defined(Q_OS_LINUX)
currentOs = "linux";
#endif
QJsonArray rules = item["rules"].toArray();
for (const QJsonValue &value : rules) {
QJsonObject rule = value.toObject();
QString action = rule["action"].toString();
bool conditionMet = false;
if (rule.contains("os")) {
QJsonObject osRule = rule["os"].toObject();
if (osRule.contains("name") && osRule["name"].toString() == currentOs) {
conditionMet = true;
}
} else {
// Правило без указания ОС применяется ко всем системам.
conditionMet = true;
}
if (conditionMet) {
if (action == "allow") {
isAllowed = true;
} else if (action == "disallow") {
isAllowed = false;
}
}
}
return isAllowed;
}
void MainWindow::on_launchButton_clicked()
{
// --- 1. Выбор версии (остается без изменений) ---
QString minecraftPath = getMinecraftPath();
if (minecraftPath.isEmpty()) {
QMessageBox::warning(this, "Ошибка", "Не удалось найти директорию .minecraft.");
return;
}
QString versionsPath = QDir::toNativeSeparators(minecraftPath + "/versions");
QDir versionsDir(versionsPath);
if (!versionsDir.exists()) {
QMessageBox::warning(this, "Ошибка", "Папка 'versions' не найдена!");
return;
}
QStringList versionList = versionsDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
if (versionList.isEmpty()) {
QMessageBox::warning(this, "Ошибка", "Не найдено ни одной установленной версии Minecraft.");
return;
}
bool ok;
QString selectedVersion = QInputDialog::getItem(this, "Выбор версии",
"Выберите версию Minecraft для запуска:",
versionList, 0, false, &ok);
if (!ok || selectedVersion.isEmpty()) {
return; // Пользователь отменил выбор
}
// --- 2. Чтение и парсинг JSON файла версии ---
QString jsonPath = QDir::toNativeSeparators(versionsPath + "/" + selectedVersion + "/" + selectedVersion + ".json");
QFile jsonFile(jsonPath);
if (!jsonFile.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, "Ошибка", "Не удалось открыть .json файл для версии " + selectedVersion);
return;
}
QByteArray jsonData = jsonFile.readAll();
jsonFile.close();
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
if (jsonDoc.isNull()) {
QMessageBox::critical(this, "Ошибка", "Некорректный .json файл для версии " + selectedVersion);
return;
}
QJsonObject rootObj = jsonDoc.object();
// --- 3. Формирование Classpath ---
QStringList classpathEntries;
QString librariesPath = QDir::toNativeSeparators(minecraftPath + "/libraries");
QJsonArray libraries = rootObj["libraries"].toArray();
for (const QJsonValue &value : libraries) {
QJsonObject library = value.toObject();
if (!checkRules(library)) {
continue; // Пропускаем библиотеку, если она не для этой ОС
}
QJsonObject downloads = library["downloads"].toObject();
if(downloads.isEmpty()){ // Для Fabric Loader и некоторых других
QString name = library["name"].toString();
QStringList parts = name.split(':');
QString path = parts[0].replace('.', '/') + "/" + parts[1] + "/" + parts[2] + "/" + parts[1] + "-" + parts[2] + ".jar";
classpathEntries << QDir::toNativeSeparators(librariesPath + "/" + path);
} else {
QJsonObject artifact = downloads["artifact"].toObject();
QString path = artifact["path"].toString();
classpathEntries << QDir::toNativeSeparators(librariesPath + "/" + path);
}
}
// Добавляем сам .jar файл игры в classpath
classpathEntries << QDir::toNativeSeparators(versionsPath + "/" + selectedVersion + "/" + selectedVersion + ".jar");
// Определяем разделитель для classpath в зависимости от ОС
QString pathSeparator;
#if defined(Q_OS_WIN)
pathSeparator = ";";
#else
pathSeparator = ":";
#endif
QString classpath = classpathEntries.join(pathSeparator);
// --- 4. Сборка аргументов ---
QStringList jvmArgs;
QStringList gameArgs;
// Аргументы для JVM
QJsonObject argumentsObj = rootObj["arguments"].toObject();
QJsonArray jvmArgsArray = argumentsObj["jvm"].toArray();
for (const QJsonValue &value : jvmArgsArray) {
if (value.isString()) {
jvmArgs << value.toString();
} else if (value.isObject()) {
if (checkRules(value.toObject())) {
QJsonArray values = value.toObject()["values"].toArray();
for(const QJsonValue &v : values){
jvmArgs << v.toString();
}
}
}
}
// Аргументы для игры
QJsonArray gameArgsArray = argumentsObj["game"].toArray();
for (const QJsonValue &value : gameArgsArray) {
if (value.isString()) {
gameArgs << value.toString();
} else if (value.isObject()) {
if (checkRules(value.toObject())) {
QJsonArray values = value.toObject()["values"].toArray();
for(const QJsonValue &v : values){
gameArgs << v.toString();
}
}
}
}
// --- 5. Подстановка значений в плейсхолдеры ---
QString nativesPath = QDir::toNativeSeparators(versionsPath + "/" + selectedVersion + "/natives");
QDir(nativesPath).mkpath("."); // Создаем папку для нативных библиотек, если ее нет
// Заменители для JVM аргументов
for (QString &arg : jvmArgs) {
arg.replace("${natives_directory}", nativesPath);
arg.replace("${launcher_name}", "CustomLauncher");
arg.replace("${launcher_version}", "1.0");
arg.replace("${classpath}", classpath);
}
// Заменители для игровых аргументов (используем базовые значения)
for (QString &arg : gameArgs) {
arg.replace("${auth_player_name}", "Player");
arg.replace("${version_name}", selectedVersion);
arg.replace("${game_directory}", minecraftPath);
arg.replace("${assets_root}", QDir::toNativeSeparators(minecraftPath + "/assets"));
arg.replace("${assets_index_name}", rootObj["assetIndex"].toObject()["id"].toString());
arg.replace("${auth_uuid}", "00000000-0000-0000-0000-000000000000");
arg.replace("${auth_access_token}", "0");
arg.replace("${clientid}", "N/A");
arg.replace("${auth_xuid}", "N/A");
arg.replace("${user_type}", "msa");
arg.replace("${version_type}", rootObj["type"].toString());
}
// --- 6. Финальная сборка и запуск ---
QString mainClass = rootObj["mainClass"].toString();
QString javaPath = "java";
QStringList finalArguments;
finalArguments << jvmArgs << mainClass << gameArgs;
ui->logOutput->appendPlainText("Запуск Minecraft версии: " + selectedVersion);
ui->logOutput->appendPlainText("Главный класс: " + mainClass);
// Для отладки можно вывести всю команду
ui->logOutput->appendPlainText("Команда: " + javaPath + " " + finalArguments.join(" "));
process->start(javaPath, finalArguments);
ui->progressBar->setVisible(true);
}
void MainWindow::on_modsFolderButton_clicked()
{
QString minecraftPath = getMinecraftPath();
if (minecraftPath.isEmpty()) {
QMessageBox::warning(this, "Ошибка", "Не удалось найти директорию .minecraft.");
return;
}
QString modsPath = minecraftPath + "/mods";
QDesktopServices::openUrl(QUrl::fromLocalFile(modsPath));
}
void MainWindow::on_settingsButton_clicked()
{
SettingsDialog dialog(this);
dialog.exec();
}
void MainWindow::on_updateModsButton_clicked()
{
QString gitRepoUrl = settings->value("gitRepoUrl").toString();
if (gitRepoUrl.isEmpty()) {
QMessageBox::information(this, "Настройки", "Пожалуйста, укажите URL Git-репозитория в настройках.");
return;
}
QString minecraftPath = getMinecraftPath();
if (minecraftPath.isEmpty()) {
QMessageBox::warning(this, "Ошибка", "Не удалось найти директорию .minecraft.");
return;
}
QString modsPath = minecraftPath + "/mods";
QDir modsDir(modsPath);
if (!modsDir.exists(".git")) {
ui->logOutput->appendPlainText("Клонирование модов из " + gitRepoUrl);
process->start("git", QStringList() << "clone" << gitRepoUrl << modsPath);
} else {
ui->logOutput->appendPlainText("Обновление модов...");
process->setWorkingDirectory(modsPath);
process->start("git", QStringList() << "pull");
}
ui->progressBar->setVisible(true);
}
void MainWindow::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
ui->progressBar->setVisible(false);
if (exitStatus == QProcess::CrashExit) {
ui->logOutput->appendPlainText("Процесс завершился с ошибкой.");
} else {
ui->logOutput->appendPlainText("Процесс успешно завершен с кодом " + QString::number(exitCode));
}
}
void MainWindow::onProcessError(QProcess::ProcessError error)
{
ui->progressBar->setVisible(false);
ui->logOutput->appendPlainText("Ошибка запуска процесса: " + process->errorString());
}
void MainWindow::readProcessOutput()
{
ui->logOutput->appendPlainText(process->readAllStandardOutput());
ui->logOutput->appendPlainText(process->readAllStandardError());
}
QString MainWindow::getMinecraftPath()
{
QString path;
#if defined(Q_OS_WIN)
path = QDir::homePath() + "/AppData/Roaming/.minecraft";
#elif defined(Q_OS_MAC)
path = QDir::homePath() + "/Library/Application Support/minecraft";
#else
path = QDir::homePath() + "/.minecraft";
#endif
return path;
}

41
mainwindow.h Normal file
View File

@@ -0,0 +1,41 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QProcess>
#include <QSettings>
// Предварительное объявление класса, сгенерированного из mainwindow.ui
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
// Слоты для кнопок (автоматически подключаются по имени: on_<имя_объекта>_<сигнал>)
void on_launchButton_clicked();
void on_modsFolderButton_clicked();
void on_updateModsButton_clicked();
void on_settingsButton_clicked();
// Слоты для QProcess (подключаются вручную)
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void onProcessError(QProcess::ProcessError error);
void readProcessOutput();
private:
QString getMinecraftPath();
Ui::MainWindow *ui; // Указатель на объект интерфейса
QProcess *process;
QSettings *settings;
};
#endif // MAINWINDOW_H

68
mainwindow.ui Normal file
View File

@@ -0,0 +1,68 @@
<?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>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Minecraft Лаунчер</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="launchButton">
<property name="text">
<string>Запустить Minecraft</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modsFolderButton">
<property name="text">
<string>Открыть папку с модами</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="updateModsButton">
<property name="text">
<string>Обновить моды из Git</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="settingsButton">
<property name="text">
<string>Настройки</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="logOutput">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -1,271 +0,0 @@
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib> // Для system()
#include <filesystem> // C++17 для работы с файловой системой
#include <fstream> // Для работы с файлами конфигурации
// Пространство имен для удобства работы с файловой системой
namespace fs = std::filesystem;
// Имя файла конфигурации для хранения URL репозитория
const std::string CONFIG_FILE = "launcher_config.txt";
// --- Функции для работы с конфигурацией ---
// Функция для сохранения URL Git-репозитория в файл
void saveGitRepository(const std::string& repoUrl) {
std::ofstream configFile(CONFIG_FILE);
if (configFile.is_open()) {
configFile << repoUrl;
configFile.close();
} else {
std::cerr << "Ошибка: Не удалось открыть файл конфигурации для записи." << std::endl;
}
}
// Функция для загрузки URL Git-репозитория из файла
std::string loadGitRepository() {
std::ifstream configFile(CONFIG_FILE);
std::string repoUrl;
if (configFile.is_open()) {
std::getline(configFile, repoUrl);
configFile.close();
}
return repoUrl;
}
// --- Кроссплатформенные функции ---
// Функция для получения пути к папке .minecraft в зависимости от ОС
fs::path getMinecraftPath() {
fs::path minecraftPath;
#if defined(_WIN32)
// Для Windows путь обычно находится в %APPDATA%\.minecraft
char* appdata = nullptr;
size_t len;
_dupenv_s(&appdata, &len, "APPDATA");
if (appdata != nullptr) {
minecraftPath = fs::path(appdata) / ".minecraft";
free(appdata);
}
#elif defined(__linux__)
// Для Linux путь обычно находится в ~/.minecraft
char* home = getenv("HOME");
if (home != nullptr) {
minecraftPath = fs::path(home) / ".minecraft";
}
#elif defined(__APPLE__)
// Для macOS путь находится в ~/Library/Application Support/minecraft
char* home = getenv("HOME");
if (home != nullptr) {
minecraftPath = fs::path(home) / "Library" / "Application Support" / "minecraft";
}
#else
std::cerr << "Неизвестная операционная система!" << std::endl;
#endif
return minecraftPath;
}
// Функция для открытия папки в файловом менеджере по умолчанию
void openFolder(const fs::path& folderPath) {
if (!fs::exists(folderPath)) {
std::cout << "Папка не существует. Создание папки: " << folderPath.string() << std::endl;
try {
fs::create_directories(folderPath);
} catch (const fs::filesystem_error& e) {
std::cerr << "Ошибка при создании папки: " << e.what() << std::endl;
return;
}
}
std::string command;
#if defined(_WIN32)
command = "explorer \"" + folderPath.string() + "\"";
#elif defined(__linux__)
command = "xdg-open \"" + folderPath.string() + "\"";
#elif defined(__APPLE__)
command = "open \"" + folderPath.string() + "\"";
#else
std::cerr << "Команда для открытия папки на данной ОС не поддерживается." << std::endl;
return;
#endif
// Выполнение системной команды
system(command.c_str());
}
// Функция для очистки содержимого папки
void clearFolder(const fs::path& folderPath) {
if (!fs::exists(folderPath) || !fs::is_directory(folderPath)) {
return; // Если папки нет, ничего не делаем
}
for (const auto& entry : fs::directory_iterator(folderPath)) {
try {
fs::remove_all(entry.path());
} catch (const fs::filesystem_error& e) {
std::cerr << "Не удалось удалить " << entry.path() << ": " << e.what() << std::endl;
}
}
}
// --- Функции меню ---
// Функция для открытия папки с модами
void openModsFolderAction() {
fs::path minecraftPath = getMinecraftPath();
if (minecraftPath.empty()) {
std::cerr << "Не удалось определить путь к папке Minecraft." << std::endl;
return;
}
fs::path modsPath = minecraftPath / "mods";
std::cout << "Путь к папке модов: " << modsPath.string() << std::endl;
openFolder(modsPath);
}
// Функция для установки URL репозитория
void setGitRepositoryAction() {
std::string repoUrl;
std::cout << "\nВведите URL Git-репозитория (например, https://github.com/user/repo.git):" << std::endl;
std::getline(std::cin >> std::ws, repoUrl); // std::ws для очистки буфера от пробельных символов
if (repoUrl.empty()) {
std::cout << "URL не может быть пустым." << std::endl;
return;
}
saveGitRepository(repoUrl);
std::cout << "URL репозитория успешно сохранен." << std::endl;
}
// Функция для загрузки модов из Git
void downloadModsAction() {
std::string repoUrl = loadGitRepository();
if (repoUrl.empty()) {
std::cout << "URL Git-репозитория не настроен. Пожалуйста, сначала установите его (пункт 2)." << std::endl;
return;
}
fs::path modsPath = getMinecraftPath() / "mods";
std::cout << "Папка для модов: " << modsPath.string() << std::endl;
// Убедимся, что папка существует
if (!fs::exists(modsPath)) {
try {
fs::create_directories(modsPath);
} catch (const fs::filesystem_error& e) {
std::cerr << "Ошибка при создании папки mods: " << e.what() << std::endl;
return;
}
}
// Запрос подтверждения перед очисткой
char confirmation;
std::cout << "\nВНИМАНИЕ! Все существующие файлы в папке 'mods' будут удалены." << std::endl;
std::cout << "Продолжить? (y/n): ";
std::cin >> confirmation;
// Проверка, что пользователь ввел 'y' или 'Y'
if (confirmation != 'y' && confirmation != 'Y') {
std::cout << "Загрузка отменена." << std::endl;
// Очистка буфера ввода после чтения символа
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
return;
}
// Очистка буфера ввода
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Очистка папки mods..." << std::endl;
clearFolder(modsPath);
std::cout << "Папка очищена." << std::endl;
// Формирование команды для клонирования репозитория
// Клонируем содержимое репозитория прямо в папку mods
std::string command = "git clone " + repoUrl + " \"" + modsPath.string() + "\"";
std::cout << "\nВыполнение команды: " << command << std::endl;
std::cout << "Начинается загрузка модов. Это может занять некоторое время..." << std::endl;
int result = system(command.c_str());
if (result == 0) {
std::cout << "Моды успешно загружены!" << std::endl;
} else {
std::cerr << "Произошла ошибка при загрузке модов. Убедитесь, что Git установлен и URL репозитория верный." << std::endl;
}
}
// Отображение главного меню
void printMenu() {
std::cout << "\n--- Minecraft Mod Launcher ---" << std::endl;
std::cout << "1. Открыть папку с модами (.minecraft/mods)" << std::endl;
std::cout << "2. Указать/изменить URL Git-репозитория с модами" << std::endl;
std::cout << "3. Загрузить/обновить моды из Git-репозитория" << std::endl;
std::cout << "4. Выход" << std::endl;
std::cout << "-----------------------------" << std::endl;
std::string currentRepo = loadGitRepository();
if (currentRepo.empty()) {
std::cout << "Текущий репозиторий: не задан" << std::endl;
} else {
std::cout << "Текущий репозиторий: " << currentRepo << std::endl;
}
std::cout << "\nВведите ваш выбор: ";
}
// --- Главная функция программы ---
int main() {
// Установка кодировки консоли для корректного отображения кириллицы в Windows
#if defined(_WIN32)
system("chcp 65001 > nul");
#endif
int choice;
while (true) {
printMenu();
std::cin >> choice;
// Проверка на корректность ввода
if (std::cin.fail()) {
std::cout << "Ошибка: введите число." << std::endl;
std::cin.clear(); // Сброс флага ошибки
// Очистка буфера ввода до следующей новой строки
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
continue;
}
switch (choice) {
case 1:
openModsFolderAction();
break;
case 2:
setGitRepositoryAction();
break;
case 3:
downloadModsAction();
break;
case 4:
std::cout << "Выход из программы." << std::endl;
return 0;
default:
std::cout << "Неверный выбор. Пожалуйста, попробуйте снова." << std::endl;
break;
}
std::cout << "\nНажмите Enter для продолжения...";
// Очистка буфера перед ожиданием Enter
if (choice != 3 && choice !=2) {
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
std::cin.get();
}
return 0;
}

27
settingsdialog.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsDialog)
{
ui->setupUi(this);
settings = new QSettings("MyCompany", "MinecraftLauncher", this);
ui->gitRepoEdit->setText(settings->value("gitRepoUrl").toString());
// Сигналы от кнопок (OK, Cancel) автоматически подключены к слотам accept() и reject()
// благодаря QDialogButtonBox и .ui файлу
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
// Эта функция будет вызвана при нажатии кнопки "OK"
void SettingsDialog::accept()
{
settings->setValue("gitRepoUrl", ui->gitRepoEdit->text());
QDialog::accept(); // Вызываем базовую реализацию, которая закрывает диалог
}

27
settingsdialog.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QDialog>
#include <QSettings>
namespace Ui {
class SettingsDialog;
}
class SettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit SettingsDialog(QWidget *parent = nullptr);
~SettingsDialog();
private slots:
void accept(); // Переопределяем слот, чтобы сохранить настройки
private:
Ui::SettingsDialog *ui;
QSettings *settings;
};
#endif // SETTINGSDIALOG_H

74
settingsdialog.ui Normal file
View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>120</height>
</rect>
</property>
<property name="windowTitle">
<string>Настройки</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>URL Git-репозитория с модами:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="gitRepoEdit"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>