Skip to content

Commit

Permalink
Add source code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Havoc committed Aug 7, 2018
1 parent ed83fd6 commit 0b5ad2b
Show file tree
Hide file tree
Showing 29 changed files with 7,621 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
# WowRealmlistManager
# WowRealmlistManager

## Note
Outdated software from 2013, kept for archive. I have no use anymore. Would need a major rewrite, see Missing Features.

## Features
* Support for all game versions
* Lightweight and clean interface

## Missing Features
* Graphical settings editor
* First start auto settings creation
* GUI update
* Enhanced context menu

## Art
The application icon "Hearthstone" was created by myself.

## Screenshot
![WowRealmlistManager](https://github.com/Havoc/WowRealmlistManager/raw/master/Screenshots/Screenshot.png "WowRealmlistManager")
Binary file added Screenshots/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions WowRealmlistManager.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WowRealmlistManager", "WowRealmlistManager/WowRealmlistManager.csproj", "{98D8349E-C38B-47F0-8AE0-E81D795E0C7F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{98D8349E-C38B-47F0-8AE0-E81D795E0C7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98D8349E-C38B-47F0-8AE0-E81D795E0C7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98D8349E-C38B-47F0-8AE0-E81D795E0C7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98D8349E-C38B-47F0-8AE0-E81D795E0C7F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions WowRealmlistManager/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
131 changes: 131 additions & 0 deletions WowRealmlistManager/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 155 additions & 0 deletions WowRealmlistManager/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Linq;

namespace WowRealmlistManager
{
public partial class MainForm : Form
{
private string language_ = "";
private bool is64bit_ = false;

public MainForm()
{
InitializeComponent();
LoadSettings();
}

private void LoadSettings()
{
try
{
XDocument xmldocument = XDocument.Load("settings.xml");

language_ = xmldocument.Descendants("Language").Select(x => x.Value).FirstOrDefault();
string architecture = xmldocument.Descendants("Architecture").Select(x => x.Value).FirstOrDefault();
if (architecture.Contains("64"))
is64bit_ = true;

var serverEntries = from server in xmldocument.Descendants("Server")
select new
{
Name = server.Descendants("Name").First().Value,
Website = server.Descendants("Website").First().Value,
Address = server.Descendants("Address").First().Value,
Version = server.Descendants("Version").First().Value,
GamePath = server.Descendants("GamePath").First().Value
};

foreach (var serverEntry in serverEntries)
{
RealmlistItem item = new RealmlistItem(serverEntry.Name, serverEntry.Website, serverEntry.Address, serverEntry.Version, serverEntry.GamePath);
lvRealmlist.Items.Add(item);
}
}
catch
{
MessageBox.Show("Failed to load settings.xml. Application will close.", "WowRealmlistManager");
Environment.Exit(-1);
}
}

private void ChangeRealmlist(RealmlistItem item)
{
if (item.Addon < Expansion.MistsOfPandaria)
{
string[] realmlistLines = File.ReadAllLines(item.GetRealmlistPath(language_));
string firstLine = "set realmlist " + item.Address;
realmlistLines[0] = firstLine;
File.WriteAllLines(item.GetRealmlistPath(language_), realmlistLines);
}
else
{
string realmlistLine = "SET realmlist \"" + item.Address + "\"";
string[] configLines = File.ReadAllLines(item.GetRealmlistPath(language_));

bool replaced = false;
for (int i = 0; i < configLines.Length; i++)
{
if (configLines[i].Contains("SET realmlist"))
{
configLines[i] = realmlistLine;
replaced = true;
break;
}
}

if (replaced)
File.WriteAllLines(item.GetRealmlistPath(language_), configLines);
else
File.AppendAllText(item.GetRealmlistPath(language_), Environment.NewLine + realmlistLine);
}
}

private void DeleteRealmlistFromConfig(RealmlistItem item)
{
if (item.Addon > Expansion.Cataclysm)
{
List<string> configLines = File.ReadAllLines(item.GetRealmlistPath(language_)).ToList<String>();

bool removed = false;
for (int i = 0; i < configLines.Count; i++)
{
if (configLines[i].Contains("SET realmlist"))
{
configLines.RemoveAt(i);
removed = true;
}
}

if (removed)
File.WriteAllLines(item.GetRealmlistPath(language_), configLines);
}
}

private void StartClickEvent(object sender, EventArgs e)
{
try
{
if (lvRealmlist.SelectedItems.Count > 0)
{
RealmlistItem item = lvRealmlist.SelectedItems[0] as RealmlistItem;

if (item.Text.Contains("Retail"))
DeleteRealmlistFromConfig(item);
else
ChangeRealmlist(item);

System.Diagnostics.Process.Start(item.GetWowPath(is64bit_));
}
}
catch
{
MessageBox.Show("Failed to start wow. Check your settings.", "WowRealmlistManager");
}
}

private void WebsiteClickEvent(object sender, EventArgs e)
{
try
{
if (lvRealmlist.SelectedItems.Count > 0)
{
RealmlistItem item = lvRealmlist.SelectedItems[0] as RealmlistItem;
if (item.Website != null)
System.Diagnostics.Process.Start(item.Website);
}
}
catch
{

}
}

private void cmsRealmList_Opening(object sender, CancelEventArgs e)
{
if (lvRealmlist.SelectedItems.Count < 1)
e.Cancel = true;
}
}
}
Loading

0 comments on commit 0b5ad2b

Please sign in to comment.