Ability to create scenarios

This commit is contained in:
Victor 2015-12-24 15:45:25 +02:00
parent c9c0cdb32e
commit d41205a04e
7 changed files with 606 additions and 0 deletions

55
public_html/create.html Normal file
View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<title>Rpy Player. Everlasting Summer</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Онлайн-плеер сценариев RenPy">
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/split.min.js"></script>
<script src="js/Utils.js"></script>
<script src="js/Transitions.js"></script>
<script src="js/Characters.js"></script>
<script src="js/MapPlaces.js"></script>
<script src="js/TokenType.js"></script>
<script src="js/Token.js"></script>
<script src="js/Lexer.js"></script>
<script src="js/Ast.js"></script>
<script src="js/Parser.js"></script>
<script src="js/Views.js"></script>
<script src="js/Main_create.js"></script>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/run.css">
<link rel="stylesheet" href="css/create.css">
</head>
<body>
<div class="container">
<div class="row">
<div id="background" class="split split-horizontal">
<div id="background1"></div>
<div id="background2"></div>
<div id="container"></div>
<div id="window">
<div id="textAuthor"></div>
<div id="textContent"></div>
</div>
<div id="mainMenuButton"></div>
<div id="menu">
<p id="menuTitle"></p>
<ul id="menuChoose">
</ul>
</div>
</div>
<div id="editor" class="split split-horizontal">
<form action="save" method="POST" onsubmit="return onpublish();">
<textarea id="source" name="source" maxlength="307200"></textarea>
<div id="controlPanel">
<input type="button" id="run" value="Запуск" />
<input type="button" id="save" value="Сохранить" />
</div>
</form>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,67 @@
.container, .row {
height: 100%;
}
body, .split {
box-sizing: border-box;
}
.gutter {
background-color: transparent;
background-repeat: no-repeat;
background-position: 50%;
}
.gutter.gutter-horizontal {
cursor: col-resize;
background-image: url('../images/vertical.png');
}
.split.split-horizontal, .gutter.gutter-horizontal {
height: 100%;
float: left;
}
#source {
width: 100%;
font-family: 'Lucida Console', 'Courier New', Courier, monospace;
font-size: 12px;
}
#controlPanel {
height: 40px;
min-height: 40px;
max-height: 40px;
}
.button, button, input[type="submit"], input[type="reset"], input[type="button"] {
display: inline-block;
height: 38px;
padding: 0 30px;
color: #555;
text-align: center;
font-size: 11px;
font-weight: 600;
line-height: 38px;
letter-spacing: .1rem;
text-transform: uppercase;
text-decoration: none;
white-space: nowrap;
background-color: transparent;
border-radius: 4px;
border: 1px solid #bbb;
cursor: pointer;
box-sizing: border-box;
}
.button:hover,
button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover,
.button:focus,
button:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
input[type="button"]:focus {
color: #219434;
border-color: #219434;
outline: 0; }

427
public_html/css/normalize.css vendored Normal file
View File

@ -0,0 +1,427 @@
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
/* HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11
* and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* Improve readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* Text-level semantics
========================================================================== */
/**
* Address styling not present in IE 8/9/10/11, Safari, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/**
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
*/
b,
strong {
font-weight: bold;
}
/**
* Address styling not present in Safari and Chrome.
*/
dfn {
font-style: italic;
}
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0;
}
/**
* Correct overflow not hidden in IE 9/10/11.
*/
svg:not(:root) {
overflow: hidden;
}
/* Grouping content
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari.
*/
figure {
margin: 1em 40px;
}
/**
* Address differences between Firefox and other browsers.
*/
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
/* Forms
========================================================================== */
/**
* Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of `select`, unless a `border` property is set.
*/
/**
* 1. Correct color not being inherited.
* Known issue: affects color of disabled elements.
* 2. Correct font properties not being inherited.
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
*/
button,
input,
optgroup,
select,
textarea {
color: inherit; /* 1 */
font: inherit; /* 2 */
margin: 0; /* 3 */
}
/**
* Address `overflow` set to `hidden` in IE 8/9/10/11.
*/
button {
overflow: visible;
}
/**
* Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct `select` style inheritance in Firefox.
*/
button,
select {
text-transform: none;
}
/**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Correct inability to style clickable `input` types in iOS.
* 3. Improve usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default;
}
/**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
input {
line-height: normal;
}
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
* `font-size` values of the `input`, it causes the cursor style of the
* decrement button to change from `default` to `text`.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Address `appearance` set to `searchfield` in Safari and Chrome.
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome
* (include `-moz` to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
/**
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
* Safari (but not Chrome) clips the cancel button when the search input has
* padding (and `textfield` appearance).
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/**
* 1. Correct `color` not being inherited in IE 8/9/10/11.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/
textarea {
overflow: auto;
}
/**
* Don't inherit the `font-weight` (applied by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold;
}
/* Tables
========================================================================== */
/**
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

View File

@ -0,0 +1,50 @@
/* global rpyscript, TextUtils */
var baseResDir = 'file:///E:/everlastingsummer/';
var ViewActivity = null;
function run(data) {
var tokens = new Lexer(data).process().getTokens();
var parser = new Parser(tokens);
ViewActivity = new Views(parser);
ViewActivity.init();
parser.next();
}
function resize() {
$('#source').css('height', ($(window).height() - $('#controlPanel').outerHeight(true) - 20) + 'px');
}
function onpublish() {
var str = String($('#source').val());
if (str.length < 400) {
alert('Сценарий слишком короткий. Минимальный размер - 400 символов');
return false;
}
if (str.length > 307200) {
alert('Сценарий слишком большой. Максимальный размер - 300 кб.');
return false;
}
return confirm('Вы действительно хотите перейти к публикации сценария?');
}
var rpyscript = 'userscenario';
function loadScenario() {
$('#source').val( JSON.parse(localStorage.customScenario) );
}
$(window).load(function(){
Split(['#background', '#editor'], {
sizes: [75, 25]
});
$(window).resize(resize);
resize();
$('#run').click(function () {
run($('#source').val());
});
$('#save').click(function () {
localStorage.customScenario = JSON.stringify($('#source').val());
});
});

1
public_html/js/split.min.js vendored Normal file
View File

@ -0,0 +1 @@
"use strict";(function(){var e=this,t="addEventListener",i="removeEventListener",s="getBoundingClientRect",r=e.attachEvent&&!e[t],n=e.document,a=function(){var e,t=["","-webkit-","-moz-","-o-"];for(var i=0;i<t.length;i++){e=n.createElement("div");e.style.cssText="width:"+t[i]+"calc(9px)";if(e.style.length){return t[i]+"calc"}}}(),o=function(e){if(typeof e==="string"||e instanceof String){return n.querySelector(e)}else{return e}},l=function(l,u){var c,f,g,p,h,z,d,S,y=[];u=typeof u!=="undefined"?u:{};if(!u.gutterSize)u.gutterSize=10;if(!u.minSize)u.minSize=100;if(!u.snapOffset)u.snapOffset=30;if(!u.direction)u.direction="horizontal";if(u.direction=="horizontal"){c="width";g="clientWidth";p="clientX";h="left";z="gutter gutter-horizontal";d="paddingLeft";S="paddingRight";if(!u.cursor)u.cursor="ew-resize"}else if(u.direction=="vertical"){c="height";g="clientHeight";p="clientY";h="top";z="gutter gutter-vertical";d="paddingTop";S="paddingBottom";if(!u.cursor)u.cursor="ns-resize"}var v=function(i){var s=this,r=s.a,n=s.b;if(!s.dragging&&u.onDragStart){u.onDragStart()}i.preventDefault();s.dragging=true;s.move=b.bind(s);s.stop=m.bind(s);e[t]("mouseup",s.stop);e[t]("touchend",s.stop);e[t]("touchcancel",s.stop);s.parent[t]("mousemove",s.move);s.parent[t]("touchmove",s.move);r[t]("selectstart",U);r[t]("dragstart",U);n[t]("selectstart",U);n[t]("dragstart",U);r.style.userSelect="none";r.style.webkitUserSelect="none";r.style.MozUserSelect="none";r.style.pointerEvents="none";n.style.userSelect="none";n.style.webkitUserSelect="none";n.style.MozUserSelect="none";n.style.pointerEvents="none";s.gutter.style.cursor=u.cursor;s.parent.style.cursor=u.cursor;M.call(s)},m=function(){var t=this,s=t.a,r=t.b;if(t.dragging&&u.onDragEnd){u.onDragEnd()}t.dragging=false;e[i]("mouseup",t.stop);e[i]("touchend",t.stop);e[i]("touchcancel",t.stop);t.parent[i]("mousemove",t.move);t.parent[i]("touchmove",t.move);delete t.stop;delete t.move;s[i]("selectstart",U);s[i]("dragstart",U);r[i]("selectstart",U);r[i]("dragstart",U);s.style.userSelect="";s.style.webkitUserSelect="";s.style.MozUserSelect="";s.style.pointerEvents="";r.style.userSelect="";r.style.webkitUserSelect="";r.style.MozUserSelect="";r.style.pointerEvents="";t.gutter.style.cursor="";t.parent.style.cursor=""},b=function(e){var t;if(!this.dragging)return;if("touches"in e){t=e.touches[0][p]-this.start}else{t=e[p]-this.start}if(t<=this.aMin+u.snapOffset){t=this.aMin}else if(t>=this.size-this.bMin-u.snapOffset){t=this.size-this.bMin}x.call(this,t);if(u.onDrag){u.onDrag()}},M=function(){var t=e.getComputedStyle(this.parent),i=this.parent[g]-parseFloat(t[d])-parseFloat(t[S]);this.size=this.a[s]()[c]+this.b[s]()[c]+this.aGutterSize+this.bGutterSize;this.percentage=Math.min(this.size/i*100,100);this.start=this.a[s]()[h]},x=function(e){this.a.style[c]=a+"("+e/this.size*this.percentage+"% - "+this.aGutterSize+"px)";this.b.style[c]=a+"("+(this.percentage-e/this.size*this.percentage)+"% - "+this.bGutterSize+"px)"},G=function(){var e=this,t=e.a,i=e.b;if(t[s]()[c]<e.aMin){t.style[c]=e.aMin-e.aGutterSize+"px";i.style[c]=e.size-e.aMin-e.aGutterSize+"px"}else if(i[s]()[c]<e.bMin){t.style[c]=e.size-e.bMin-e.bGutterSize+"px";i.style[c]=e.bMin-e.bGutterSize+"px"}},w=function(){var e=this,t=e.a,i=e.b;if(i[s]()[c]<e.bMin){t.style[c]=e.size-e.bMin-e.bGutterSize+"px";i.style[c]=e.bMin-e.bGutterSize+"px"}else if(t[s]()[c]<e.aMin){t.style[c]=e.aMin-e.aGutterSize+"px";i.style[c]=e.size-e.aMin-e.aGutterSize+"px"}},E=function(e){for(var t=0;t<e.length;t++){M.call(e[t]);G.call(e[t])}for(t=e.length-1;t>=0;t--){M.call(e[t]);w.call(e[t])}},U=function(){return false},D=o(l[0]).parentNode;if(!u.sizes){var k=100/l.length;u.sizes=[];for(f=0;f<l.length;f++){u.sizes.push(k)}}if(!Array.isArray(u.minSize)){var L=[];for(f=0;f<l.length;f++){L.push(u.minSize)}u.minSize=L}for(f=0;f<l.length;f++){var O=o(l[f]),B=f==1,F=f==l.length-1,A,C=u.gutterSize,N;if(f>0){N={a:o(l[f-1]),b:O,aMin:u.minSize[f-1],bMin:u.minSize[f],dragging:false,parent:D,isFirst:B,isLast:F,direction:u.direction};N.aGutterSize=u.gutterSize;N.bGutterSize=u.gutterSize;if(B){N.aGutterSize=u.gutterSize/2}if(F){N.bGutterSize=u.gutterSize/2}}if(!r){if(f>0){var R=n.createElement("div");R.className=z;R.style[c]=u.gutterSize+"px";R[t]("mousedown",v.bind(N));R[t]("touchstart",v.bind(N));D.insertBefore(R,O);N.gutter=R}if(f===0||f==l.length-1){C=u.gutterSize/2}if(typeof u.sizes[f]==="string"||u.sizes[f]instanceof String){A=u.sizes[f]}else{A=a+"("+u.sizes[f]+"% - "+C+"px)"}}else{if(typeof u.sizes[f]==="string"||u.sizes[f]instanceof String){A=u.sizes[f]}else{A=u.sizes[f]+"%"}}O.style[c]=A;if(f>0){y.push(N)}}E(y)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){exports=module.exports=l}exports.Split=l}else{e.Split=l}}).call(window);

6
public_html/run.js Normal file
View File

@ -0,0 +1,6 @@
/* global rpyscript, TextUtils, userscenario */
function run(e){var s=new Lexer(e).process().getTokens(),r=new Parser(s)
ViewActivity=new Views(r),ViewActivity.init(),r.next()}var baseResDir="/resources/es/",ViewActivity=null
$(document).ready(function(){if("undefined"==typeof rpyscript||TextUtils.isEmpty(rpyscript))rpyscript="undefined",run('play music music_list["everlasting_summer"]\nscene bg ext_square_day\nshow mz smile pioneer far at fright\nshow us grin sport far at fleft\nshow mt smile pioneer far at right\nshow mi smile pioneer far at left\nshow dv smile pioneer2 at cright\nshow sl smile pioneer at cleft\nshow un smile2 pioneer at center\nall "Приглашаем тебя в Бесконечное Лето!"')
else{var e="undefined"==typeof userscenario&&userscenario?"scripts":"userscenarios"
$.get("/resources/es/"+e+"/"+rpyscript+".rpy",run)}})