Skip to content

Commit

Permalink
Start work on web version
Browse files Browse the repository at this point in the history
  • Loading branch information
Grauenwolf committed Nov 22, 2017
1 parent 1bc1944 commit 8541f79
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<Setting>
<Setting Name="Super Powers">
<References>
<Reference Name="Arcana" />
</References>
Expand Down
2 changes: 1 addition & 1 deletion SavageTools/SavageToolsWeb/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Web;
using System.Web.Optimization;

namespace SavageToolsWeb
namespace SavageTools.Web
{
public class BundleConfig
{
Expand Down
2 changes: 1 addition & 1 deletion SavageTools/SavageToolsWeb/App_Start/FilterConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Web;
using System.Web.Mvc;

namespace SavageToolsWeb
namespace SavageTools.Web
{
public class FilterConfig
{
Expand Down
2 changes: 1 addition & 1 deletion SavageTools/SavageToolsWeb/App_Start/RouteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Web.Mvc;
using System.Web.Routing;

namespace SavageToolsWeb
namespace SavageTools.Web
{
public class RouteConfig
{
Expand Down
2 changes: 1 addition & 1 deletion SavageTools/SavageToolsWeb/App_Start/WebApiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Web.Http;

namespace SavageToolsWeb
namespace SavageTools.Web
{
public static class WebApiConfig
{
Expand Down
39 changes: 39 additions & 0 deletions SavageTools/SavageToolsWeb/Content/Site.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,42 @@ select,
textarea {
max-width: 280px;
}


#listofthings {
list-style-type: none;
}

#listofthings li {
width: 300px;
display: inline-block;
vertical-align: top;
}




table.gridtable {
font-family: verdana,arial,sans-serif;
font-size: 11px;
color: #333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}

table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}

table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
9 changes: 3 additions & 6 deletions SavageTools/SavageToolsWeb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SavageTools.Web.Models;
using System.Web.Mvc;

namespace SavageToolsWeb.Controllers
namespace SavageTools.Web.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
return View(new HomeIndexViewModel());
}

public ActionResult About()
Expand Down
2 changes: 1 addition & 1 deletion SavageTools/SavageToolsWeb/Global.asax
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%@ Application Codebehind="Global.asax.cs" Inherits="SavageToolsWeb.MvcApplication" Language="C#" %>
<%@ Application Codebehind="Global.asax.cs" Inherits="SavageTools.Web.MvcApplication" Language="C#" %>
15 changes: 9 additions & 6 deletions SavageTools/SavageToolsWeb/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace SavageToolsWeb
namespace SavageTools.Web
{
public class MvcApplication : System.Web.HttpApplication
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{
Expand All @@ -18,6 +15,12 @@ protected void Application_Start()
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);

s_AppDataPath = Server.MapPath("~/bin/Settings");
}

static string s_AppDataPath;

public static string AppDataPath { get => s_AppDataPath; }
}
}
49 changes: 49 additions & 0 deletions SavageTools/SavageToolsWeb/Models/HomeIndexViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using SavageTools.Settings;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Xml.Serialization;

namespace SavageTools.Web.Models
{
public class HomeIndexViewModel
{
static readonly XmlSerializer SettingXmlSerializer = new XmlSerializer(typeof(Setting));
static List<Setting> s_Settings;

public HomeIndexViewModel()
{
if (s_Settings == null)
{
var settings = new List<Setting>();

var root = new System.IO.DirectoryInfo(MvcApplication.AppDataPath);
foreach (var file in root.GetFiles("*.savage-setting"))
{
Setting book;
// Open document
using (var stream = file.OpenRead())
book = (Setting)SettingXmlSerializer.Deserialize(stream);

settings.Add(book);
}
s_Settings = settings;
}
}

public IEnumerable<SelectListItem> SettingList()
{
//yield return new SelectListItem() { Text = "", Value = "" };
foreach (var setting in s_Settings)
yield return new SelectListItem() { Text = setting.Name, Value = setting.Name };

}

public IEnumerable<SelectListItem> RankList()
{
//yield return new SelectListItem() { Text = "", Value = "" };
foreach (var setting in s_Settings)
yield return new SelectListItem() { Text = setting.Name, Value = setting.Name };

}
}
}
4 changes: 2 additions & 2 deletions SavageTools/SavageToolsWeb/SavageToolsWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SavageToolsWeb</RootNamespace>
<RootNamespace>SavageTools.Web</RootNamespace>
<AssemblyName>SavageToolsWeb</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
Expand Down Expand Up @@ -156,6 +156,7 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Models\HomeIndexViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -198,7 +199,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<Content Include="fonts\glyphicons-halflings-regular.woff" />
Expand Down
3 changes: 2 additions & 1 deletion SavageTools/SavageToolsWeb/Views/Home/About.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>

<p>Use this area to provide additional information.</p>
<p>The source code for this project is available on <a href="https://github.com/Grauenwolf/SavageTools/">GitHub</a></p>

57 changes: 55 additions & 2 deletions SavageTools/SavageToolsWeb/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@{
@model SavageTools.Web.Models.HomeIndexViewModel
@{
ViewBag.Title = "Home Page";
}

<div class="jumbotron">
@*<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="https://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
Expand All @@ -28,4 +29,56 @@
<p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
<p><a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>
</div>
</div>*@

<div class="row">
<h2>NPC Generator</h2>
<table class="gridtable">
<tr>
<th>Setting</th>
<td>
@Html.DropDownList("setting", Model.SettingList(), new { onchange = "SettingChanged($('#setting')[0].value, $('#archetype')[0])" })
</td>
<th>Archetype</th>
<td>
<select id="archetype"></select>
</td>
<th>Race</th>
<td>
<select id="race"></select>
</td>
<th>Rank</th>
<td>
@Html.DropDownList("rank", Model.RankList())
</td>

<th>Count</th>
<td>
<input type="number" id="count" value="1" />
</td>
<td rowspan="2" valign="middle">
<input id="showCharacterScreen" type="button" value="Generate Squad" />
</td>
</tr>
<tr>
<td colspan="2"></td>


<td colspan="2">
<label><input type="checkbox" id="randomArchetype" />Random</label>

</td>
<td colspan="2">
<label><input type="checkbox" id="randomRace" />Random</label>

</td>
<td colspan="2">
<label><input type="checkbox" id="randomRank" />Random</label>

</td>
<td colspan="2"></td>

</tr>

</table>
</div>
2 changes: 1 addition & 1 deletion SavageTools/SavageToolsWeb/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
@Html.ActionLink("Savage Tools", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
Expand Down
2 changes: 1 addition & 1 deletion SavageTools/SavageToolsWeb/Views/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="SavageToolsWeb" />
<add namespace="SavageTools.Web" />
</namespaces>
</pages>
</system.web.webPages.razor>
Expand Down

0 comments on commit 8541f79

Please sign in to comment.