Difference between revisions of "SoC2011 Student Page Aethaeryn"

From The Battle for Wesnoth Wiki
(Questionnaire: this should, in theory, make the quesitonnaire collapsable)
(Questionnaire: using the table directly from the MediaWiki documentation to see if this helps)
Line 132: Line 132:
  
 
==Questionnaire==
 
==Questionnaire==
<div class="collapsible collapsed toccolours">
+
{| class="collapsible collapsed wikitable"
 +
|-
 +
! Aethaeryn's Questionnaire
 +
|-
 +
|
 
===Basics===
 
===Basics===
  
Line 141: Line 145:
 
'''1.2) State your preferred email address.'''
 
'''1.2) State your preferred email address.'''
  
[spambot paranoia]
+
[see GSOC submission page]
  
 
'''1.3) If you have chosen a nick for IRC and Wesnoth forums, what is it?'''
 
'''1.3) If you have chosen a nick for IRC and Wesnoth forums, what is it?'''
Line 164: Line 168:
  
 
Because of my overly-ambitious academic goals, there's no way to not take summer classes if I ever intend on graduating, but I'm only going to be taking two (last summer I took four). I have a Monday/Wednesday/Thursday math class from 9:00 AM to 11:05 AM (eastern US time), May 31st to July 8th. I have a Monday/Tuesday/Thursday math class from 1:00 PM to 3:05 PM, May 31st to July 22nd. Other than that, I have no social life outside of school (and it's summer break) and IRC (all except two on my default join list are Wesnoth-related channels). I never go on any vacations. So yes, those time slots are literally my only other time commitments for the entirety of summer. For much of May and all of August, I will be doing nothing of importance at all and probably would be spending it on Wesnoth anyway.
 
Because of my overly-ambitious academic goals, there's no way to not take summer classes if I ever intend on graduating, but I'm only going to be taking two (last summer I took four). I have a Monday/Wednesday/Thursday math class from 9:00 AM to 11:05 AM (eastern US time), May 31st to July 8th. I have a Monday/Tuesday/Thursday math class from 1:00 PM to 3:05 PM, May 31st to July 22nd. Other than that, I have no social life outside of school (and it's summer break) and IRC (all except two on my default join list are Wesnoth-related channels). I never go on any vacations. So yes, those time slots are literally my only other time commitments for the entirety of summer. For much of May and all of August, I will be doing nothing of importance at all and probably would be spending it on Wesnoth anyway.
 +
 +
|-
 +
|
  
 
===Experience===
 
===Experience===
Line 230: Line 237:
  
 
I will not be able to submit a patch by the application deadline, but they will be [http://wiki.wesnoth.org/SoC2011_Student_Page_Aethaeryn#Patches here] when I have the time.
 
I will not be able to submit a patch by the application deadline, but they will be [http://wiki.wesnoth.org/SoC2011_Student_Page_Aethaeryn#Patches here] when I have the time.
 +
 +
|-
 +
|
  
 
===Communication skills===
 
===Communication skills===
Line 260: Line 270:
  
 
I have no problem with coding many, many hours on my own once I know what I'm supposed to be coding, but I definitely don't want to waste hours working on something that's just going to be thrown out, so I definitely will seek feedback as much as necessary in order to not waste any time/effort.
 
I have no problem with coding many, many hours on my own once I know what I'm supposed to be coding, but I definitely don't want to waste hours working on something that's just going to be thrown out, so I definitely will seek feedback as much as necessary in order to not waste any time/effort.
 +
 +
|-
 +
|
  
 
===Project===
 
===Project===
Line 294: Line 307:
  
 
I've been with the Wesnoth community since 2007. I'm staying.
 
I've been with the Wesnoth community since 2007. I'm staying.
 +
 +
|-
 +
|
  
 
===Practical considerations===
 
===Practical considerations===
Line 326: Line 342:
 
'''5.4) Would you mind talking with your mentor on telephone / internet phone? We would like to have a backup way for communications for the case that somehow emails and IRC do fail. If you are willing to do so, please do list a phone number (including international code) so that we are able to contact you. You should probably *only* add this number in the application for you submit to google since the info in the wiki is available in public. We will *not* make any use of your number unless some case of "there is no way to contact you" does arise!'''
 
'''5.4) Would you mind talking with your mentor on telephone / internet phone? We would like to have a backup way for communications for the case that somehow emails and IRC do fail. If you are willing to do so, please do list a phone number (including international code) so that we are able to contact you. You should probably *only* add this number in the application for you submit to google since the info in the wiki is available in public. We will *not* make any use of your number unless some case of "there is no way to contact you" does arise!'''
  
[spambot paranoia]
+
[see GSOC submission page]
</div>
+
|}

Revision as of 18:06, 8 April 2011


This page is related to Summer of Code 2011
See the list of Summer of Code 2011 Ideas



This is a Summer of Code 2011 student page
Project: SoC_Ideas_Your_Own_Ideas2011



Description

Michael Babich - Improving Lua's User Interface Capabilities

I intend to improve the ability for add-ons to customize the user interface through Lua. I will focus on providing simple, but powerful syntax for a set of functions that will enable add-on creators to have improved, easier access to features that already exist within the game engine so that they are free to creatively provide more innovative content.

The purpose of this project is to act as a middleman between the game engine and the add-on creators using the Lua scripting language so that simple and powerful add-on creation can help revolutionize future MP, just as [set_menu_item] and [option] allowed for a great evolution in the quality of add-ons since 1.3. This interface framework needs to be as broad as possible in the time given and the scope allowed so that creative add-on authors themselves can stretch Wesnoth content far beyond its traditional style, but it also must provide a simplified Lua helper library so that everyone can use it without necessarily having to delve deeply into the complexity that exists in the currently-existing GUI.

IRC

Aethaeryn

Introduction

I have been making content for Wesnoth since 2007 and I have been gradually porting much of my more advanced content to Lua since late 2009. While doing so, I have noticed certain limitations to the current implementation of Lua as it relates to add-on creation, especially with certain elements only possible through WML or the rather poorly readable WML tables. As the title suggests, I wish to simply and extend the add-on creation capabilities in Lua. In particular, I will be working with various elements of the interface code because this is currently where Lua is weak and often just relying on WML tables. There are several problems with using WML tables in these areas:

  • Poor readability, clumsy syntax, and verbosity. The metatable in the helper library helps with readability, but does not always work (for instance on [or] and [and] boxes, where those words are reserved in Lua) and it still hides the underlying issue that true native Lua support is not there. It also is fairly difficult in certain applications where the XML-style WML syntax is clearly inferior and much more verbose than something done in pure Lua.
  • You're essentially using WML. This defeats the purpose of using Lua in the first place if the majority of your code in a particular area is in WML. This is made even more severe when one realizes that many of the areas that must currently be done via WML tables are complex things that are the kind of things best done in a real language in the first place. In particular, the [message], [option], and [set_menu_item] have no real Lua equivalent.
  • Calling Lua from WML tables is hacky. Currently, if one wants to call a Lua function from T.option {}, one has to set a string that is a call on a global Lua function.

An ideal scenario or campaign would be one that uses WML to define the basic structure and then call on Lua for any more advanced elements. As I spend most of my Wesnoth time making -- or playing -- content for MP that do things that WML was not originally intended to do, such as making Wesnoth an RPG instead of a TBS, I have noticed that WML does not scale very well as a general purpose language doing advanced scripting. Any traditional language, such as Lua, can handle certain advanced things in a much more readable and efficient manner, but there are certain gaps in Lua where WML tables must be integrated with the Lua, which defeats many of the primary reasons to use Lua in the first place.

Fortunately, the solution is rather obvious to the WML table problem. Lua needs to be extended to access features that almost all already exist in the game engine and these must be implemented through Lua functions and tables instead of WML tables so that the full benefits of using Lua for scripting can be realized. Although the problem and solution are fairly easy to describe, certain precautions must be taken to make ensure that save games are not broken and no new issues are introduced. In addition, the individual proposed changes must be enumerated for clarity as to the scope of the project.

The Implementation: Overview

The information can roughly be broken down into three separate phases, 0 through 2. First, I shall go through an overview so as to be straightforward with the overall planned changes, then I shall provide the details of each individual section, and finally I shall propose a detailed timeline as to when each part can be accomplished.

Phase 0: The Initial Changes

First, src/scripting/lua.cpp should be split into smaller, logically-organized files so that the file does not grow too large and unmanageable with the improvements planned. This has the additional effect of allowing me to get familiar with the core Lua code.

Next, various UI tags shall be implemented in native Lua without WML tables. The hardest portion of this is ensuring that the Lua changes can be implemented without breaking save files. Most of the existing WML code can be reused, so a key purpose of this is to get rid of the need for WML tables for this portion of the code so that it better interacts with files written purely in Lua and so it is in a consistent style with code in the later portion of this project. The tags that need to be ported to Lua functions:

  • [message]
    • [option]
    • [text_input]
  • [set_menu_item]

Phase 1: Complex Interface Changes

  • Implement improved Lua access to the in-scenario GUI stuff, again without WML table hacks.
    • This includes improving the syntax and implementation of the dialog Lua.
  • A way to take in text commands in a way similar to debug mode's :lua, but only using specific commands to do specific actions as defined by Lua code in the add-on.

Phase 2: Simplify Add-on Creation

  • Implement Lua "ui" package similar to helper that adds an additional abstraction layer on top of Phase 1 to simplify it for add-on creators.
  • Create a similar implementation to the above through newly-defined WML tags.
  • (The original implemenation will still exist for those who want more control and customizability, while this implementation is available for those who do not wish to deal with the complexity that the interface can actually provide.)

The Implementation: Details

I'm sleeping. This section will be filled out when I can think again.

Phase 0

Sample Syntax

local msg = gui_message{
   message  = "Hello world!",
   settings = {
      speaker = "narrator",
      image   = "wesnoth.png"
   },
   options  = {
         { text='hello', callback = foobar() },
         { text='goodbye', callback = say_goodbye() }
    }}

local msg2 = gui_message{
   message = "What's your name?",
   -- no "settings =" makes it set reasonable defaults
   -- text_input takes either a table containing the information, or a table of tables that are all valid text_input
   text_input = {variable = "foo", label = "Name: ", max_length = 42}
}

if side = host then
   msg.show

function foobar()
   msg2.show

gui_message()

option

callback

text_input

set_menu_item()

Phase 1

Dialog Improvements

GUI 2 Access

Commands?

Phase 2

Sample syntax

The final goal is to use wesnoth.ui.show() to hide almost all of the interface details by providing a syntactical shortcut to the functions in Phase 0 and Phase 1. More complexity will be possible, as in sample2, but the extremely basic sample1 will be legal syntax as well.

sample1  = {message = "Hello world"}
sample2 = {message = {"Hello world", options = {speaker = "Konrad", side_for = 1}}}
wesnoth.ui.show(sample1)
wesnoth.ui.show(sample2)

This will allow for possibilities like the following, where the GUI message is literally as simple as providing one string:

function message_all(messageText)
   wesnoth.ui.show{message = messageText}

wesnoth.ui

WML additions

The Implementation: Timeline

now April 08 - April 22   Discuss details of the implementation with the various developers so that the proposal is ready for the summer. Work on basic patches, especially in the early areas of Phase 0, so that commit access can be granted before the designated GSOC period. Most of the design needs to be finalized in this period.
April 23 - May 08 Continue to familiarize myself with the project and its code by doing more of Phase 0.
May 09 - May 18 Spring semester ends. Availability may be limited during this period. (The days might be slightly off depending on what the final exam schedule is.)
May 19 - May 30 My schedule should be entirely free in this time span, so Phase 0 should be completed (if it isn't already finished) and substantial progress should be made on Phase 1.
May 31 - June 30 The entire month of June will be spent on Phase 1.
July 4 - July 8 Expected busy week as my one summer course wraps up.
July 9 - July 17 Phase 1, the bulk of the project, should be concluding around this point. Since this is around the middle evaluation point, part of the focus should be on reviewing the design and plans for the second half of GSOC. If I am ahead of schedule or behind schedule, adjustments can be made.
July 18 - July 22 Expected busy week as my other summer course wraps up.
July 23 - August 15  Phase 2. Again, my schedule should be entirely free to focus on the project.
August 15 According to Google: "'pencils down' date. Take a week to scrub code, write tests, improve documentation, etc."
lim t
t→∞
Continue to work on Wesnoth's Lua scripting capabilities because it certainly will take more than just one summer to perfect it.

Goals

Patches

Work on the Phase 0 patches will resume immediately after this document is finished and submitted.

Questionnaire