Skip to content

Commit

Permalink
Crossfade between Author and Name for mariobar
Browse files Browse the repository at this point in the history
  • Loading branch information
dram55 committed Aug 21, 2019
1 parent 677042c commit d9755e1
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 28 deletions.
19 changes: 16 additions & 3 deletions MarioMaker2OCR/MarioMaker2OCR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<Reference Include="Emgu.CV.World, Version=4.1.0.3420, Culture=neutral, PublicKeyToken=7281126722ab4438, processorArchitecture=MSIL">
<HintPath>..\packages\EMGU.CV.4.1.0.3420\lib\net35\Emgu.CV.World.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=1.2.0.246, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.2.0\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -198,6 +201,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<None Include="tessdata\seg.traineddata" />
<None Include="Test\testdata\video\720\Dram_Video_Gameplay_1.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="web\mariobar\super-mario-maker-2.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -411,6 +417,15 @@
<Content Include="web\drambar\index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web\drambar\innerfade-directive.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web\drambar\innerfade.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web\drambar\lib\jquery-3.4.1.min.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web\drambar\settings.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -481,9 +496,7 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Folder Include="Test\testdata\video\720\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\EMGU.CV.4.1.0.3420\build\EMGU.CV.targets" Condition="Exists('..\packages\EMGU.CV.4.1.0.3420\build\EMGU.CV.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
26 changes: 16 additions & 10 deletions MarioMaker2OCR/Test/GameplayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.Zip;
using System.IO;

namespace MarioMaker2OCR.Test
{
Expand All @@ -17,15 +19,14 @@ public class GameplayTests
[TestMethod]
public void TenMinuteGameplayTest()
{
// Commented out for now since this is above githubs 100MB filesize limit - even when compressed.
// Will make a smaller test in the near future.
//
// Here is the video: https://drive.google.com/file/d/1NMpA4z2AvedB4bbhtWvXrIlV4QuBxRTC/view?usp=sharing
//
//VideoCapture deathVideo = new VideoCapture(@"Test\testdata\video\720\Dram_Gameplay_Test_1.mp4");
VideoCapture deathVideo = new VideoCapture(@"");
return;
// Unzip video
FastZip fastZip = new FastZip();
string zip = @"Test\testdata\video\720\Dram_Video_Gameplay_1.zip";
string dir = @"Test\testdata\video\720\";
string videoFile = dir + "Dram_Video_Gameplay_1.mp4";
fastZip.ExtractZip(zip, dir, "");

VideoCapture deathVideo = new VideoCapture(videoFile);

// Read first frame, for some reason the Bitmap is null - so we don't want this going to the VideoProcessor
deathVideo.Read(new Mat());
Expand Down Expand Up @@ -74,7 +75,6 @@ public void TenMinuteGameplayTest()
}
};


mockedVideoProcessor.Start(true);

Assert.AreEqual(4, deathCount, "Death Check");
Expand All @@ -96,7 +96,13 @@ public void TenMinuteGameplayTest()
}

Console.WriteLine("Unknown Template Count: " + unknownTemplateCount);


try
{
File.Delete(videoFile);
}
catch(Exception ex)
{}
}
}
}
Binary file not shown.
1 change: 1 addition & 0 deletions MarioMaker2OCR/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net461" />
<package id="MSTest.TestFramework" version="1.4.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net461" />
<package id="SharpZipLib" version="1.2.0" targetFramework="net461" />
<package id="Unosquare.Swan.Lite" version="1.3.1" targetFramework="net461" />
<package id="ZedGraph" version="5.1.7" targetFramework="net461" />
</packages>
3 changes: 3 additions & 0 deletions MarioMaker2OCR/web/drambar/drambar.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
state.level = newLevel;
state.deathCount = 0;

// For use in <inner-fade> directive
state.fadeItems = [newLevel.name, newLevel.author];

startTimer();
state.levelCleared = false;
}
Expand Down
18 changes: 14 additions & 4 deletions MarioMaker2OCR/web/drambar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Drambar</title>
<script src="/drambar/lib/jquery-3.4.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.js"></script>
<script src="https://cdn.rawgit.com/AngularClass/angular-websocket/v2.0.0/dist/angular-websocket.js"></script>
<script src="/drambar/drambar.js"></script>
<script src="/drambar/settings.js"></script>
<script src="/drambar/innerfade-directive.js"></script>

<link rel="stylesheet" href="/drambar/style.css">
</head>
Expand All @@ -18,10 +20,18 @@
ng-class="((ctrl.state.hideCurrentLevel) ? 'slide-out-' : 'slide-in-')+ctrl.settings.slideFromDirection"
ng-style="{'font-size':ctrl.settings.fontSize, 'font-family':ctrl.settings.mainFont,
'background-color':ctrl.settings.backgroundColor, 'border':ctrl.settings.border}">
<h4 ng-if="ctrl.state.level.author && ctrl.settings.isLevelAuthorVisible"
ng-style="{color:ctrl.settings.levelAuthorColor}" class="user-name">{{ctrl.state.level.author}}</h4>
<p class="level-name" ng-if="ctrl.settings.isLevelNameVisible"
ng-style="{color:ctrl.settings.levelNameColor}">{{ctrl.state.level.name}}</p>

<div ng-if="!ctrl.settings.innerFadeAuthorAndName || ctrl.settings.innerFadeAuthorAndName <= 0">
<h4 ng-if="ctrl.state.level.author && ctrl.settings.isLevelAuthorVisible"
ng-style="{color:ctrl.settings.levelAuthorColor}" class="user-name">{{ctrl.state.level.author}}</h4>
<p class="level-name" ng-if="ctrl.settings.isLevelNameVisible"
ng-style="{color:ctrl.settings.levelNameColor}">{{ctrl.state.level.name}}</p>
</div>

<div ng-if="ctrl.settings.innerFadeAuthorAndName > 0">
<inner-fade items="ctrl.state.fadeItems" interval="ctrl.settings.innerFadeAuthorAndName"></inner-fade>
</div>

<code ng-if="ctrl.state.level.code && ctrl.settings.isLevelCodeVisible"
class="level-code text-uppercase" ng-style="{color:ctrl.settings.levelCodeColor, 'font-family':ctrl.settings.levelCodeFont}">{{ctrl.state.level.code}}</code>
<div class="timer-death-bar">
Expand Down
77 changes: 77 additions & 0 deletions MarioMaker2OCR/web/drambar/innerfade-directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
(function(){
'use strict';

var app = angular.module('dramBarApp');
app.controller('innerFadeController', innerFadeController);
app.directive('innerFade', innerFadeDirective);

// innerFadeDirective
//
// Pass in a list of strings and they will cycle every x milliseconds
// with a fadeIn/fadeOut transition. Similar to a slideshow.
//
// The container is sized to the largest string in the given items.
//
// Usage:
// <inner-fade items="ctrl.listOfStrings" interval="8000"></inner-fade>
//
innerFadeDirective.inject = ['$interval', '$timeout'];
function innerFadeDirective($interval, $timeout) {
return {
restrict: 'E',
templateUrl: '/drambar/innerfade.html',
scope: {
items: '<',
interval: '<'
},
controller: innerFadeController,
controllerAs: 'innerfade',
bindToController: true,
link: function innerFadeLink(scope, element) {

// on items change
scope.$watchCollection('innerfade.items', function() {
if (scope.innerfade.items)
scope.innerfade.longestItem = scope.innerfade.items.reduce(function (a, b) { return a.length > b.length ? a : b; });
});

// wrap in $timeout to allow DOM to load children
$timeout(function(){
var children = element.find("p.inner-fade-item");
var visibleIndex = 0;
var maxIndex = children.length;

// hide children by default
angular.forEach(jQuery(children), function(value, key) {
var child = angular.element(value);
child.hide();
});

// immediately display first child
jQuery(element).show();
jQuery(children[0]).fadeTo(500, 1);

// cycle through all elements - for each interval
$interval(function() {
// Get next element index
var nextIndex = visibleIndex + 1;
if (nextIndex >= maxIndex)
nextIndex = 0;

// fade out current element
jQuery(children[visibleIndex]).fadeTo(500, 0, function(){
// display next element
jQuery(children[nextIndex]).fadeTo(500, 1);
});

// increment index
visibleIndex = nextIndex;

}, scope.innerfade.interval); // interval

}, 100); // timeout
}
}
}
function innerFadeController() {}
})();
15 changes: 15 additions & 0 deletions MarioMaker2OCR/web/drambar/innerfade.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="inner-fade-container">

<p class="inner-fade-size" style="opacity:0;">
{{innerfade.longestItem}}
</p>
<p class="inner-fade-item" ng-repeat="item in innerfade.items track by $index"
style="position: absolute;
left: 0;
right: 0;
top: 9px;
margin-left: auto;
margin-right: auto;">
{{item}}
</p>
</div>
2 changes: 2 additions & 0 deletions MarioMaker2OCR/web/drambar/lib/jquery-3.4.1.min.js

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions MarioMaker2OCR/web/drambar/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
isLevelAuthorVisible:true,
isLevelCodeVisible:true,


// innerFadeAuthorAndName: 8000, // not yet supported.

// How do they look?
slideFromDirection:'left', //left|right|top|bottom
Expand All @@ -32,9 +32,23 @@
backgroundColor: 'rgba(0, 0, 0, 0.77)',



//Other options
playTimerWarning:false,
playTimerWarningAt:15, //minutes

// SMM Colors
//
//rgba(61, 80, 174, 1) // Blue
//rgba(20, 33, 112, 1) // Dark Blue
//rgba(38, 174, 160, 1) // Teal
//rgba(227, 143, 21, 1) // Dark Yellow
//rgba(220, 70, 116, 1) // Pink

//rgba(250, 205, 0, 1) // Yellow //#facd00
//rgba(92, 28, 28, 1) // Dark Brown //#5c1c1c

// 4th argument in rbga(0,0,0,X) is opacity.
// 0 = not visible.
// 1 = opaque
});
})();
18 changes: 13 additions & 5 deletions MarioMaker2OCR/web/mariobar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Mariobar</title>
<script src="/drambar/lib/jquery-3.4.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.js"></script>
<script src="https://cdn.rawgit.com/AngularClass/angular-websocket/v2.0.0/dist/angular-websocket.js"></script>
<script src="/drambar/drambar.js"></script>
<script src="/mariobar/settings.js"></script>
<script src="/drambar/innerfade-directive.js"></script>

<link rel="stylesheet" href="/mariobar/style.css">
</head>
Expand All @@ -19,10 +21,16 @@
ng-style="{'font-size':ctrl.settings.fontSize, 'font-family':ctrl.settings.mainFont,
'background-color':ctrl.settings.backgroundColor, 'border':ctrl.settings.border}">

<h4 ng-if="ctrl.state.level.author && ctrl.settings.isLevelAuthorVisible"
ng-style="{color:ctrl.settings.levelAuthorColor}" class="user-name">{{ctrl.state.level.author}}</h4>
<p class="level-name" ng-if="ctrl.settings.isLevelNameVisible"
ng-style="{color:ctrl.settings.levelNameColor}">{{ctrl.state.level.name}}</p>
<div ng-if="!ctrl.settings.innerFadeAuthorAndName || ctrl.settings.innerFadeAuthorAndName <= 0">
<h4 ng-if="ctrl.state.level.author && ctrl.settings.isLevelAuthorVisible"
ng-style="{color:ctrl.settings.levelAuthorColor}" class="user-name">{{ctrl.state.level.author}}</h4>
<p class="level-name" ng-if="ctrl.settings.isLevelNameVisible"
ng-style="{color:ctrl.settings.levelNameColor}">{{ctrl.state.level.name}}</p>
</div>

<div ng-if="ctrl.settings.innerFadeAuthorAndName > 0">
<inner-fade items="ctrl.state.fadeItems" interval="ctrl.settings.innerFadeAuthorAndName"></inner-fade>
</div>

<hr ng-if="ctrl.settings.isLevelNameVisible || ctrl.settings.isLevelAuthorVisible"
ng-style="{'border-color': ctrl.settings.lineColor, 'background-color':ctrl.settings.lineColor}">
Expand All @@ -31,7 +39,7 @@
class="level-code text-uppercase" ng-style="{color:ctrl.settings.levelCodeColor, 'font-family':ctrl.settings.levelCodeFont}">{{ctrl.state.level.code}}</p>


<div class="timer-death-bar">
<div class="timer-death-bar">
<div ng-if="ctrl.settings.isTimerVisible" class="level-timer"
ng-style="{'color':(ctrl.state.levelCleared) ? ctrl.settings.timerColorOnClear : ctrl.settings.timerFontColor}">
<img src="/drambar/images/smw_clock_dark.png">
Expand Down
8 changes: 5 additions & 3 deletions MarioMaker2OCR/web/mariobar/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
isTimerVisible:true,
isDeathCountVisible:true,
isLevelNameVisible:true,
isLevelAuthorVisible:false,
isLevelAuthorVisible:true,
isLevelCodeVisible:true,

innerFadeAuthorAndName: 8000, // fade between level name and level author
// set this to 0 to display both separately

// How do they look?
slideFromDirection:'left', //left|right|top|bottom
Expand All @@ -34,7 +36,7 @@
playTimerWarning:false,
playTimerWarningAt:15, //minutes

// SMM Colors
// SMM Colors
//
//rgba(61, 80, 174, 1) // Blue
//rgba(20, 33, 112, 1) // Dark Blue
Expand All @@ -45,7 +47,7 @@
//rgba(250, 205, 0, 1) // Yellow //#facd00
//rgba(92, 28, 28, 1) // Dark Brown //#5c1c1c

// 4th argument in rbga(0,0,0,X) is opacity.
// 4th argument in rbga(0,0,0,X) is opacity.
// 0 = not visible.
// 1 = opaque
});
Expand Down
2 changes: 1 addition & 1 deletion MarioMaker2OCR/web/mariobar/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ h4 {
padding: 9px 13px 3px 13px;
background-color: rgba(0, 0, 0, 0.77);
border-radius: 8px;
color: white;
color: black;
max-width: 350px;
bottom:0;
margin-left:5px;
Expand Down

0 comments on commit d9755e1

Please sign in to comment.