Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MK2k committed Apr 27, 2017
1 parent 9a1637f commit e528212
Show file tree
Hide file tree
Showing 204 changed files with 144,769 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Metropolis_Launcher/moby.db filter=lfs diff=lfs merge=lfs -text
Metropolis_Launcher/rombase.db filter=lfs diff=lfs merge=lfs -text
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vs/**/*
Metropolis_Launcher/bin/**/*
Metropolis_Launcher/obj/**/*
Metropolis_Launcher/Metropolis_Launcher.vbproj.user
9 changes: 9 additions & 0 deletions COMPILING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Compiling Metropolis Launcher

You need Visual Studio 2015 or higher (VS14) as well as DevExpress 15.2 (both commercial products *duh*) in order to compile Metropolis Launcher from source.

Anything else is provided in the project on this github.

# Target CPU

Currently, only x86 is supported, you should switch from "Any CPU" to the "x86" profile when compiling.
51 changes: 51 additions & 0 deletions Metropolis_Launcher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Metropolis_Launcher", "Metropolis_Launcher\Metropolis_Launcher.vbproj", "{FAFBA71A-26CF-4A0D-B880-F467C92BF104}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
DebugTEST|Any CPU = DebugTEST|Any CPU
DebugTEST|x64 = DebugTEST|x64
DebugTEST|x86 = DebugTEST|x86
PreRelease|Any CPU = PreRelease|Any CPU
PreRelease|x64 = PreRelease|x64
PreRelease|x86 = PreRelease|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Debug|Any CPU.ActiveCfg = Debug|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Debug|Any CPU.Build.0 = Debug|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Debug|x64.ActiveCfg = Debug|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Debug|x64.Build.0 = Debug|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Debug|x86.ActiveCfg = Debug|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Debug|x86.Build.0 = Debug|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.DebugTEST|Any CPU.ActiveCfg = DebugTEST|Any CPU
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.DebugTEST|Any CPU.Build.0 = DebugTEST|Any CPU
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.DebugTEST|x64.ActiveCfg = DebugTEST|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.DebugTEST|x64.Build.0 = DebugTEST|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.DebugTEST|x86.ActiveCfg = DebugTEST|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.DebugTEST|x86.Build.0 = DebugTEST|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.PreRelease|Any CPU.ActiveCfg = PreRelease|Any CPU
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.PreRelease|Any CPU.Build.0 = PreRelease|Any CPU
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.PreRelease|x64.ActiveCfg = PreRelease|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.PreRelease|x64.Build.0 = PreRelease|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.PreRelease|x86.ActiveCfg = PreRelease|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.PreRelease|x86.Build.0 = PreRelease|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Release|Any CPU.ActiveCfg = Release|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Release|x64.ActiveCfg = Release|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Release|x64.Build.0 = Release|x64
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Release|x86.ActiveCfg = Release|x86
{FAFBA71A-26CF-4A0D-B880-F467C92BF104}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions Metropolis_Launcher/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings/>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="dll" />
</assemblyBinding>
</runtime>
</configuration>
17 changes: 17 additions & 0 deletions Metropolis_Launcher/Classes/cls_3IntVec.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Public Class cls_3IntVec
Public _x As Integer
Public _y As Integer
Public _z As Integer

Public Sub New(Optional ByVal x As Integer = 0, Optional ByVal y As Integer = 0, Optional ByVal z As Integer = 0)
Me._x = x
Me._y = y
Me._z = z
End Sub

Public Sub Add(ByVal vec As cls_3IntVec)
Me._x += vec._x
Me._y += vec._y
Me._z += vec._z
End Sub
End Class
11 changes: 11 additions & 0 deletions Metropolis_Launcher/Classes/cls_3ObjVec.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Public Class cls_3ObjVec
Public _x As Object
Public _y As Object
Public _z As Object

Public Sub New(Optional ByVal x As Object = Nothing, Optional ByVal y As Object = Nothing, Optional ByVal z As Object = Nothing)
Me._x = x
Me._y = y
Me._z = z
End Sub
End Class
23 changes: 23 additions & 0 deletions Metropolis_Launcher/Classes/cls_AddGameStats.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Public Class cls_AddGameStats
Public _new As Integer
Public _links As Integer
Public _duplicates_added As Integer
Public _duplicates_replaced As Integer
Public _duplicates_ignored As Integer

Public Sub New(Optional ByVal [new] As Integer = 0, Optional ByVal links As Integer = 0, Optional ByVal duplicates_added As Integer = 0, Optional ByVal duplicates_replaced As Integer = 0, Optional ByVal duplicates_ignored As Integer = 0)
Me._new = [new]
Me._links = [links]
Me._duplicates_added = duplicates_added
Me._duplicates_replaced = duplicates_replaced
Me._duplicates_ignored = duplicates_ignored
End Sub

Public Sub Add(ByVal addGameStats As cls_AddGameStats)
Me._new += addGameStats._new
Me._links += addGameStats._links
Me._duplicates_added += addGameStats._duplicates_added
Me._duplicates_replaced += addGameStats._duplicates_replaced
Me._duplicates_ignored += addGameStats._duplicates_ignored
End Sub
End Class
215 changes: 215 additions & 0 deletions Metropolis_Launcher/Classes/cls_Extras.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
Public Class cls_Extras
Public Class cls_Extras_Result
Public _Path As String = ""
Public _ExtraNum As Integer = 0
Public _NoExtraFound As Boolean = True
Public _ExtraType As Object = Nothing

Public Sub New(ByVal Path As String, ByVal ExtraNum As Integer, ByVal NoExtraFound As Boolean, ByVal ExtraType As Object)
_Path = Path
_ExtraNum = ExtraNum
_NoExtraFound = NoExtraFound
_ExtraType = ExtraType
End Sub
End Class

Public Shared _SupportedExtensions As String() = {".png", ".jpg", ".bmp"}
Public Shared _SupportedExtensions_Masks As String() = {"*.png", "*.jpg", "*.bmp"}

Public Shared Function FindNextExtraFromSupportedExtensions(ByVal PathWithoutExtension) As String
For Each ext As String In _SupportedExtensions
If Alphaleonis.Win32.Filesystem.File.Exists(PathWithoutExtension & ext) Then
Return PathWithoutExtension & ext
End If
Next

Return ""
End Function

Public Shared Function getExtraSuffix(ExtraNum) As String
If ExtraNum = 0 Then
Return ""
Else
Return "_" & ExtraNum.ToString.PadLeft(3, "0")
End If
End Function

Public Shared Function FindNextExtra(ByVal id_Emu_Games As Integer, ByVal ExtraNum As Integer, ByVal SkipToNextImmediately As Boolean, ByVal ExtraType As Object, Optional ByVal IgnoreHiddenExtraCategories As Boolean = False, Optional ByVal LimitToExtraType As Boolean = False) As cls_Extras_Result
Dim dt_Emu_Games As New DS_ML.src_ucr_Emulation_GamesDataTable

Using tran As SQLite.SQLiteTransaction = cls_Globals.Conn.BeginTransaction
DS_ML.Fill_src_ucr_Emulation_Games(tran, dt_Emu_Games, Nothing, Nothing, Nothing, id_Emu_Games)
End Using

If dt_Emu_Games.Rows.Count <> 1 Then Return New cls_Extras_Result("", 0, True, Nothing)
Dim row_Emu_Games As DataRow = dt_Emu_Games.Rows(0)

Dim Platform_Short As String = TC.NZ(row_Emu_Games("Platform_Short"), "")
Dim id_Moby_Platforms As Integer = row_Emu_Games("id_Moby_Platforms")
Dim Game As String = TC.NZ(row_Emu_Games("Game"), "")

Dim FileName As String = ""
If TC.NZ(row_Emu_Games("InnerFile"), "") <> "" Then
FileName = row_Emu_Games("InnerFile")
Else
FileName = row_Emu_Games("File")
End If

Return FindNextExtra(Platform_Short, id_Moby_Platforms, Game, FileName, ExtraNum, SkipToNextImmediately, ExtraType, IgnoreHiddenExtraCategories, LimitToExtraType)
End Function

Public Shared Function FindNextExtra(ByVal Platform_Short As String, ByVal id_Moby_Platforms As Integer, ByVal Game As String, ByVal FileName As String, ByVal ExtraNum As Integer, ByVal SkipToNextImmediately As Boolean, ByVal ExtraType As Object, Optional ByVal IgnoreHiddenExtraCategories As Boolean = False, Optional ByVal LimitToExtraType As Boolean = False) As cls_Extras_Result
If TC.NZ(ExtraType, "").Length = 0 Then Return New cls_Extras_Result("", 0, True, Nothing)

If SkipToNextImmediately Then
ExtraNum = ExtraNum + 1
End If

Dim bDone As Boolean = False
Dim iNext As Integer = 0

Dim sPlatform As String = Platform_Short
Dim sRom As String = ""

Dim NoExtraFound As Boolean = False

Select Case TC.NZ(id_Moby_Platforms, 0)
Case cls_Globals.enm_Moby_Platforms.win
sRom = GetExtraFilename(Game, FileName)
Case Else
sRom = Alphaleonis.Win32.Filesystem.Path.GetFileNameWithoutExtension(TC.NZ(FileName, ""))
End Select

Dim sNextExtra As String = ""

While Not bDone AndAlso iNext < 2
Dim sFileName As String = FindNextExtraFromSupportedExtensions(cls_Globals.Dir_Extras & "\emulation\" & sPlatform & "\" & ExtraType & "\" & sRom & getExtraSuffix(ExtraNum)) 'IIf(ExtraNum = 0, "", " [image" & (ExtraNum + 1) & "]")

If Alphaleonis.Win32.Filesystem.File.Exists(sFileName) Then
sNextExtra = sFileName
bDone = True
Else
If Not LimitToExtraType Then
ExtraType = DataAccess.FireProcedureReturnScalar(cls_Globals.Conn, 0, "SELECT Name FROM tbl_Emu_Extras WHERE Sort = (SELECT MIN(Sort) FROM tbl_Emu_Extras WHERE" & IIf(IgnoreHiddenExtraCategories, "", " IFNULL(Hide, 0) = 0 AND ") & " Sort > (SELECT Sort FROM tbl_Emu_Extras WHERE Name = '" & ExtraType & "')) LIMIT 1")
Else
iNext = iNext + 1
End If
ExtraNum = 0

If TC.NZ(ExtraType, "").Length = 0 Then
ExtraType = DataAccess.FireProcedureReturnScalar(cls_Globals.Conn, 0, "SELECT Name FROM tbl_Emu_Extras WHERE Sort = (SELECT MIN(Sort) from tbl_Emu_Extras " & IIf(IgnoreHiddenExtraCategories, "", "WHERE IFNULL(Hide, 0) = 0") & ") LIMIT 1")
iNext = iNext + 1
End If
End If
End While

If iNext = 2 Then
NoExtraFound = True
End If

Return New cls_Extras_Result(sNextExtra, ExtraNum, NoExtraFound, ExtraType)
End Function

''' <summary>
''' Find all Extras according to FileName
''' </summary>
''' <param name="Platform_Short"></param>
''' <param name="id_Moby_Platforms"></param>
''' <param name="Game"></param>
''' <param name="FileName"></param>
''' <returns>ArrayList of cls_Extras_Result</returns>
Public Shared Function FindAllExtras(ByVal Platform_Short As String, ByVal id_Moby_Platforms As Integer, ByVal Game As String, ByVal FileName As String) As ArrayList
Dim Result As New ArrayList

Dim bDone As Boolean = False

Dim ExtraType As Object = DataAccess.FireProcedureReturnScalar(cls_Globals.Conn, 0, "SELECT Name FROM tbl_Emu_Extras WHERE Sort = (SELECT MIN(Sort) from tbl_Emu_Extras LIMIT 1)")

Dim ExtraNum As Integer = 0

Dim bFirst As Boolean = True

While Not bDone
Dim res As cls_Extras_Result = FindNextExtra(Platform_Short, id_Moby_Platforms, Game, FileName, ExtraNum, Not bFirst, ExtraType, True)

If bFirst Then bFirst = False

If res._NoExtraFound Then
bDone = True
Exit While
Else
If Not ExtrasListContains(Result, res) Then
Result.Add(res)
Else
bDone = True
Exit While
End If
End If

ExtraNum = res._ExtraNum
ExtraType = res._ExtraType
End While

Return Result
End Function

Public Shared Function ExtrasListContains(ByRef ExtrasList As ArrayList, ByRef Extra As cls_Extras_Result) As Boolean
For Each item As cls_Extras_Result In ExtrasList
If item._Path.ToLower = Extra._Path.ToLower Then
Return True
End If
Next

Return False
End Function

Public Shared Function ExtrasListsEqual(ByRef ExtrasList1 As ArrayList, ByRef ExtrasList2 As ArrayList) As Boolean
If ExtrasList1.Count <> ExtrasList2.Count Then Return False

For Each item As cls_Extras_Result In ExtrasList1
If Not ExtrasListContains(ExtrasList2, item) Then Return False
Next

Return True
End Function

''' <summary>
''' Get the next free extra filename without extension (for later save)
''' </summary>
''' <param name="Platform_Short">The short name for the platform, e.g. snes, gen, win etc.</param>
''' <param name="ExtraCategory">The extra category</param>
''' <param name="FileName">The ROM filename without its extension</param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function FindNextFreeExtraFilename(ByVal Platform_Short As String, ByVal ExtraCategory As String, ByVal FileName As String) As String
If Not Alphaleonis.Win32.Filesystem.Directory.Exists(cls_Globals.Dir_Extras & "\emulation\" & Platform_Short & "\" & ExtraCategory) Then
Try
Alphaleonis.Win32.Filesystem.Directory.CreateDirectory(cls_Globals.Dir_Extras & "\emulation\" & Platform_Short & "\" & ExtraCategory)
Catch ex As Exception
Return ""
End Try
End If

Dim ExtraNum As Integer = 0

Dim bDone As Boolean = False

While Not bDone
If Alphaleonis.Win32.Filesystem.File.Exists(FindNextExtraFromSupportedExtensions(cls_Globals.Dir_Extras & "\emulation\" & Platform_Short & "\" & ExtraCategory & "\" & FileName & getExtraSuffix(ExtraNum))) Then 'IIf(ExtraNum = 0, "", " [image" & (ExtraNum + 1) & "]")
ExtraNum += 1
Else
bDone = True
End If
End While

Return FileName & getExtraSuffix(ExtraNum) ' IIf(ExtraNum = 0, "", " [image" & (ExtraNum + 1) & "]")
End Function

Public Shared Function GetExtraFilename(ByVal Game As String, ByVal FileName As String) As String
If Game.ToLower = FileName.ToLower Then
Return Alphaleonis.Win32.Filesystem.Path.GetFileNameWithoutExtension(MKNetLib.cls_MKStringSupport.GetCleanFileName(TC.NZ(Game, "")))
Else
Return MKNetLib.cls_MKStringSupport.GetCleanFileName(TC.NZ(Game, ""))
End If
End Function
End Class
Loading

0 comments on commit e528212

Please sign in to comment.