Skip to content

Commit

Permalink
Merge branch 'feature/source-code-reorganization' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
weeeBox committed Dec 21, 2016
2 parents ed7b820 + e67c575 commit e3f2f9d
Show file tree
Hide file tree
Showing 299 changed files with 3,304 additions and 4,690 deletions.
1 change: 0 additions & 1 deletion Builder/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source 'https://rubygems.org'

gem 'rake'
gem 'mechanize'
gem 'colorize'
28 changes: 3 additions & 25 deletions Builder/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,14 @@ GEM
remote: https://rubygems.org/
specs:
colorize (0.7.7)
domain_name (0.5.23)
unf (>= 0.0.5, < 1.0.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
mechanize (2.7.3)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0)
mime-types (~> 2.0)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
mime-types (2.4.3)
mini_portile (0.6.2)
net-http-digest_auth (1.4)
net-http-persistent (2.9.4)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
ntlm-http (0.1.1)
rake (0.9.2.2)
unf (0.1.4)
unf_ext
unf_ext (0.0.6)
webrobots (0.1.1)

PLATFORMS
ruby

DEPENDENCIES
colorize
mechanize
rake

BUNDLED WITH
1.13.6
9 changes: 4 additions & 5 deletions Builder/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace :lunar do

task :init do

$bin_release_unity = resolve_path '/Applications/Unity4/Unity.app/Contents/MacOS/Unity'
$bin_release_unity = resolve_path '/Applications/Unity5/Unity.app/Contents/MacOS/Unity'

$dir_builder = File.expand_path '.'
$dir_publisher_project = resolve_path "#{$dir_builder}/PublisherProject"
Expand All @@ -21,13 +21,12 @@ namespace :lunar do

$dir_project = resolve_path File.expand_path('../Project')
$dir_project_assets = resolve_path "#{$dir_project}/Assets"
$dir_project_assets_plugins = resolve_path "#{$dir_project_assets}/Plugins"
$dir_project_assets_plugins_unity = resolve_path "#{$dir_project_assets_plugins}/Lunar"
$dir_project_assets_editor = resolve_path "#{$dir_project_assets}/Editor"
$dir_project_assets_plugins_unity = resolve_path "#{$dir_project_assets}/LunarPlugin"
$dir_project_assets_editor = resolve_path "#{$dir_project_assets_plugins_unity}/Editor"

def extract_package_version(dir_project)

file_version = resolve_path "#{dir_project}/Assets/Plugins/Lunar/Version.cs"
file_version = resolve_path "#{dir_project}/Assets/LunarPlugin/Scripts/LPVersion.cs" # fixme: embed in configuration
source = File.read file_version

source =~ /VERSION\s+=\s+"(\d+\.\d+.\d+b?)"/
Expand Down
33 changes: 9 additions & 24 deletions Builder/unity_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,21 @@ module UnityHelper

############################################################

def self.list_package_assets dir_project, ignored_files = []
def self.list_package_assets(dir_project, ignored_files = [])

dir_project_assets = resolve_path "#{dir_project}/Assets"
dir_project_assets_editor = resolve_path "#{dir_project_assets}/Editor/Lunar"
dir_project_assets_plugins = resolve_path "#{dir_project_assets}/Plugins/Lunar"
dir_project_plugin = resolve_path "#{dir_project}/Assets/LunarPlugin"

files = []

# list editor files
list_assets files, dir_project_assets_editor, &->(file) {
# list files
list_assets files, dir_project_plugin, &->(file) {

# don't include ignored files
return false if ignored_files.include?(File.basename file)
# don't include ignored files
return false if ignored_files.include?(File.basename file)

# the rest is fine
return true
}

# list runtime files
list_assets files, dir_project_assets_plugins, &->(file) {

# don't include ignored files
return false if ignored_files.include?(File.basename file)

# include all directories
return true if File.directory?(file)

# the rest is fine
return true
}
# the rest is fine
return true
}

return files

Expand Down
6 changes: 3 additions & 3 deletions Project/Assets/Editor/Lunar.meta → Project/Assets/LunarPlugin.meta
100755 → 100644

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

File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions ...s/Editor/Lunar/Console/AbstractConsole.cs → ...Plugin/Editor/Console/CAbstractConsole.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,34 @@

namespace LunarEditor
{
interface IConsoleDelegate
interface ICConsoleDelegate
{
void OnConsoleEntryAdded(AbstractConsole console, ref ConsoleViewCellEntry entry);
void OnConsoleCleared(AbstractConsole console);
void OnConsoleEntryAdded(CAbstractConsole console, ref CConsoleViewCellEntry entry);
void OnConsoleCleared(CAbstractConsole console);
}

#if LUNAR_DEVELOPMENT
public // looks ugly but works for Unit testing
#endif

class AbstractConsole : IDestroyable, IConsoleDelegate
class CAbstractConsole : ICDestroyable, ICConsoleDelegate
{
public AbstractConsole(int historySize)
public CAbstractConsole(int historySize)
{
Entries = new CycleArray<ConsoleViewCellEntry>(historySize);
Entries = new CCycleArray<CConsoleViewCellEntry>(historySize);
Delegate = this; // use null-object to avoid constant null reference checks
}

internal void Add(ConsoleViewCellEntry entry)
internal void Add(CConsoleViewCellEntry entry)
{
if (ThreadUtils.IsUnityThread())
if (CThreadUtils.IsUnityThread())
{
Entries.Add(entry);
Delegate.OnConsoleEntryAdded(this, ref entry);
}
else
{
TimerManager.ScheduleTimer(() =>
CTimerManager.ScheduleTimer(() =>
{
Add(entry);
});
Expand All @@ -81,11 +81,11 @@ public virtual void Destroy()

#region IConsoleDelegate null implementation

public void OnConsoleEntryAdded(AbstractConsole console, ref ConsoleViewCellEntry entry)
public void OnConsoleEntryAdded(CAbstractConsole console, ref CConsoleViewCellEntry entry)
{
}

public void OnConsoleCleared(AbstractConsole console)
public void OnConsoleCleared(CAbstractConsole console)
{
}

Expand All @@ -95,8 +95,8 @@ public void OnConsoleCleared(AbstractConsole console)

#region Properties

internal CycleArray<ConsoleViewCellEntry> Entries { get; private set; }
internal IConsoleDelegate Delegate { get; set; }
internal CCycleArray<CConsoleViewCellEntry> Entries { get; private set; }
internal ICConsoleDelegate Delegate { get; set; }

public int Capacity
{
Expand All @@ -107,16 +107,16 @@ public int Capacity
#endregion
}

struct AttributedString
struct CAttributedString
{
public static readonly AttributedString Null = default(AttributedString);
public static readonly CAttributedString Null = default(CAttributedString);

public string value;
public Rect position;
public int foregroundColor, backgroundColor;
public int flags;

public AttributedString(string value, float x = 0, float y = 0, float w = 0, float h = 0, int foregroundColor = 0, int backgroundColor = 0)
public CAttributedString(string value, float x = 0, float y = 0, float w = 0, float h = 0, int foregroundColor = 0, int backgroundColor = 0)
{
this.value = value != null ? value : "";
this.position = new Rect(x, y, w, h);
Expand Down Expand Up @@ -159,7 +159,7 @@ public float h
#endregion
}

interface ITextMeasure
interface ICTextMeasure
{
Vector2 CalcSize(string text);
float CalcHeight(string text, float width);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace LunarEditor
{
using Option = CCommand.Option;

public class CommandAutocompletion
public class CCommandAutocompletion
{
private static readonly string[] EMPTY_SUGGESTIONS = new string[0]; // TODO: rename
private static readonly string[] SINGLE_SUGGESTION = new string[1]; // TODO: rename
Expand Down Expand Up @@ -99,7 +99,7 @@ private static string[] getSuggestions(string line, string token)

private static string[] getSuggestions(string commandLine, IList<string> tokens)
{
Iterator<string> iter = new Iterator<string>(tokens);
CIterator<string> iter = new CIterator<string>(tokens);

CCommand cmd = CRegistery.FindCommand(iter.Next());
if (cmd == null)
Expand All @@ -121,7 +121,7 @@ private static string[] getSuggestions(string commandLine, IList<string> tokens)
iter.Position = iterPos;
return getSuggestedOptions(iter, cmd, optionName, "--");
}
else if (token.StartsWith("-") && !StringUtils.IsNumeric(token)) // short option
else if (token.StartsWith("-") && !CStringUtils.IsNumeric(token)) // short option
{
string optionName = token.Substring(1);
if (SkipOption(iter, cmd, optionName)) continue;
Expand Down Expand Up @@ -162,13 +162,13 @@ private static string[] getSuggestions(IList<CCommand> commands)
//////////////////////////////////////////////////////////////////////////////
// Options

private static bool SkipOption(Iterator<string> iter, CCommand cmd, string name)
private static bool SkipOption(CIterator<string> iter, CCommand cmd, string name)
{
Option opt = cmd.FindOption(name);
return opt != null && SkipOption(iter, opt) && iter.HasNext();
}

private static bool SkipOption(Iterator<string> iter, Option opt)
private static bool SkipOption(CIterator<string> iter, Option opt)
{
Type type = opt.Target.FieldType;

Expand Down Expand Up @@ -220,7 +220,7 @@ private static bool IsValidOptionString(string value)
return Option.IsValidValue(typeof(string), value); // don't actually check types: just format
}

private static string[] getSuggestedOptions(Iterator<string> iter, CCommand cmd, string optNameToken, string prefix)
private static string[] getSuggestedOptions(CIterator<string> iter, CCommand cmd, string optNameToken, string prefix)
{
List<Option> optionsList = new List<Option>(); // TODO: reuse list

Expand Down Expand Up @@ -294,20 +294,20 @@ private static string getSuggestedOption(Option opt, bool useShort)
{
if (useShort)
{
return StringUtils.C("-" + opt.ShortName, ColorCode.TableVar);
return CStringUtils.C("-" + opt.ShortName, CColorCode.TableVar);
}

return StringUtils.C("--" + opt.Name, ColorCode.TableVar);
return CStringUtils.C("--" + opt.Name, CColorCode.TableVar);
}

private static bool isOptionNameMatch(Option opt, string token, bool useShort)
{
if (useShort)
{
return opt.ShortName != null && StringUtils.EqualsIgnoreCase(opt.ShortName, token);
return opt.ShortName != null && CStringUtils.EqualsIgnoreCase(opt.ShortName, token);
}

return StringUtils.EqualsIgnoreCase(opt.Name, token);
return CStringUtils.EqualsIgnoreCase(opt.Name, token);
}


Expand Down Expand Up @@ -337,9 +337,9 @@ private static string[] getSuggestedArgs(IList<string> values, string token)
List<string> sortedValues = new List<string>(values.Count);
for (int i = 0; i < values.Count; ++i)
{
if (token.Length == 0 || StringUtils.StartsWithIgnoreCase(StringUtils.RemoveRichTextTags(values[i]), token))
if (token.Length == 0 || CStringUtils.StartsWithIgnoreCase(CStringUtils.RemoveRichTextTags(values[i]), token))
{
sortedValues.Add(StringUtils.RemoveRichTextTags(values[i]));
sortedValues.Add(CStringUtils.RemoveRichTextTags(values[i]));
}
}

Expand Down Expand Up @@ -373,13 +373,13 @@ private static string[] singleSuggestion(string suggestion)

private static string toDisplayName(CCommand cmd)
{
ColorCode color = cmd is CVarCommand ? ColorCode.TableVar : cmd.ColorCode;
return StringUtils.C(cmd.Name, color);
CColorCode color = cmd is CVarCommand ? CColorCode.TableVar : cmd.ColorCode;
return CStringUtils.C(cmd.Name, color);
}

private static IList<string> getTokens(string line)
{
IList<string> tokens = CommandTokenizer.Tokenize(line, CommandTokenizer.OPTION_IGNORE_MISSING_QUOTES);
IList<string> tokens = CCommandTokenizer.Tokenize(line, CCommandTokenizer.OPTION_IGNORE_MISSING_QUOTES);
if (tokens.Count > 0 && line.EndsWith(" "))
{
tokens.Add(""); // treat last space as "empty" token
Expand Down
Loading

0 comments on commit e3f2f9d

Please sign in to comment.