Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

/src/.flashProjectProperties
/src/common/skse.as
/src/common/skyui
/src/common/skyui

# wip, random tests or notes that I don't want to version control
__*

14 changes: 13 additions & 1 deletion src/CLIK/Mouse.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// Mouse object
//****************************************************************************

// See:
// Scaleform AS2 Extensions Reference.pdf
// http://gameware.autodesk.com/documents/gfx_4.0_as2_extensions.pdf

intrinsic class Mouse
{
static function addListener(listener:Object):Void;
Expand All @@ -13,4 +17,12 @@ intrinsic class Mouse
// scaleform extensions
// static function getTopMostEntity(obj1:Object,obj2:Number,obj3:Boolean):Object;
static function getTopMostEntity():Object;
}

/**
* This method returns coordinates of the corresponding mouse cursor, in _root
* coordinate space. The returned value is an instance of flash.geom.Point.
*
* Scaleform version: 2.2
*/
static function getPosition(mouseIndex:Number):flash.geom.Point;
}
129 changes: 117 additions & 12 deletions src/common/Shared/BSScrollingList.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,50 @@ import gfx.ui.InputDetails;
import gfx.ui.NavigationCode;
import gfx.events.EventDispatcher;

/*
Method summary:

function BSScrollingList()
function ClearList(): Void
function GetClipByIndex(aiIndex: Number): MovieClip
function handleInput(details: InputDetails, pathToFocus: Array): Boolean
function set selectedIndex(aiNewIndex: Number): Void
function set listAnimating(abFlag: Boolean): Void
function doSetSelectedIndex(aiNewIndex:Number, aiKeyboardOrMouse: Number): Void
function set scrollPosition(aiNewPosition: Number): Void
function updateScrollPosition(aiPosition: Number): Void
function UpdateList(): Void
function InvalidateData(): Void
function SetScrollbarVisibility(): Void
function CalculateMaxScrollPosition(): Void
function GetEntryHeight(aiEntryIndex: Number): Number
function moveSelectionUp(): Void
function moveSelectionDown(): Void

function onLoad(): Void
function onMouseWheel(delta: Number): Void
function onItemPress(aiKeyboardOrMouse: Number): Void
function onItemPressAux(aiKeyboardOrMouse: Number, aiButtonIndex: Number)
function onScroll(event: Object): Void

function SetEntry(aEntryClip: MovieClip, aEntryObject: Object): Void
function SetEntryText(aEntryClip: MovieClip, aEntryObject: Object): Void

Getters/Setters:

function get selectedIndex(): Number
function get listAnimating(): Boolean
function get selectedEntry(): Object
function get scrollPosition(): Number
function get maxScrollPosition(): Number
function get entryList(): Array
function get disableSelection(): Boolean
function get disableInput(): Boolean
function get maxEntries(): Number
function get textOption(): Number

*/

class Shared.BSScrollingList extends MovieClip
{
static var TEXT_OPTION_NONE: Number = 0;
Expand Down Expand Up @@ -34,6 +78,7 @@ class Shared.BSScrollingList extends MovieClip
var iScrollPosition: Number;
var iScrollbarDrawTimerID: Number;
var iSelectedIndex: Number;
var iHighlightedIndex: Number; // new
var iTextOption: Number;
var itemIndex: Number;

Expand All @@ -48,6 +93,7 @@ class Shared.BSScrollingList extends MovieClip
Mouse.addListener(this);

iSelectedIndex = -1;
iHighlightedIndex = -1;
iScrollPosition = 0;
iMaxScrollPosition = 0;
iListItemsShown = 0;
Expand All @@ -58,16 +104,19 @@ class Shared.BSScrollingList extends MovieClip

for (var item: MovieClip = GetClipByIndex(iMaxItemsShown); item != undefined; item = GetClipByIndex(++iMaxItemsShown)) {
item.clipIndex = iMaxItemsShown;

item.onRollOver = function ()
{
if (!_parent.listAnimating && !_parent.bDisableInput && itemIndex != undefined) {
_parent.doSetSelectedIndex(itemIndex, 0);
//GlobalFunc.getInstance().Deebug("onRollOver() doSetSelectedIndex " + itemIndex);
_parent.doSetSelectedIndex(itemIndex, 0, true);
_parent.bMouseDrivenNav = true;
}
};
item.onPress = function (aiMouseIndex, aiKeyboardOrMouse)
{
if (itemIndex != undefined) {
//GlobalFunc.getInstance().Deebug("item::onPress() " + aiKeyboardOrMouse);
_parent.onItemPress(aiKeyboardOrMouse);
if (!_parent.bDisableInput && onMousePress != undefined)
onMousePress();
Expand Down Expand Up @@ -101,6 +150,7 @@ class Shared.BSScrollingList extends MovieClip

function handleInput(details: InputDetails, pathToFocus: Array): Boolean
{
//GlobalFunc.getInstance().Deebug("handleInput() BSScrollingList");
var bHandledInput: Boolean = false;
if (!bDisableInput) {
var item: MovieClip = GetClipByIndex(selectedIndex - scrollPosition);
Expand Down Expand Up @@ -156,6 +206,50 @@ class Shared.BSScrollingList extends MovieClip
bListAnimating = abFlag;
}

//fabd++ The function can now set mouse highlight (visual) separately from the selected state
function doSetSelectedIndex(aiNewIndex:Number, aiKeyboardOrMouse: Number, abMouseFocus: Boolean): Void
{
// current focus is selectedindex, or mouse highlighted index (decoupled from selection)
var iCurHighlightIndex = iHighlightedIndex; // abMouseFocus ? iHighlightedIndex : iSelectedIndex;

if (!bDisableSelection) {

// change selectedIndex, unless explicitly doing the mouse highlighting
if (abMouseFocus !== true) {
iSelectedIndex = aiNewIndex;
}

if (aiNewIndex != iCurHighlightIndex) {
var iCurrentIndex: Number = iHighlightedIndex;

iHighlightedIndex = aiNewIndex;
//GlobalFunc.getInstance().Deebug("iHighlightedIndex = " + iHighlightedIndex);

if (iCurrentIndex != -1)
SetEntry(GetClipByIndex(EntriesA[iCurrentIndex].clipIndex), EntriesA[iCurrentIndex]);

if (iHighlightedIndex != -1) {
if (iPlatform != 0) {
if (iHighlightedIndex < iScrollPosition)
scrollPosition = iHighlightedIndex;
else if (iHighlightedIndex >= iScrollPosition + iListItemsShown)
scrollPosition = Math.min(iHighlightedIndex - iListItemsShown + 1, iMaxScrollPosition);
else
SetEntry(GetClipByIndex(EntriesA[iHighlightedIndex].clipIndex),EntriesA[iHighlightedIndex]);
} else {
SetEntry(GetClipByIndex(EntriesA[iHighlightedIndex].clipIndex),EntriesA[iHighlightedIndex]);
}
}

// note: this could have unwanted effects here, since highlighted is not always *selected*
// note: OR... dispatch only when selectedIndex changes... usually would want highlight change
dispatchEvent({type:"selectionChange", index:iHighlightedIndex, keyboardOrMouse:aiKeyboardOrMouse});
}
}
}

//fabd-- the old code for reference
/*
function doSetSelectedIndex(aiNewIndex:Number, aiKeyboardOrMouse: Number): Void
{
if (!bDisableSelection && aiNewIndex != iSelectedIndex) {
Expand All @@ -180,6 +274,7 @@ class Shared.BSScrollingList extends MovieClip
dispatchEvent({type:"selectionChange", index:iSelectedIndex, keyboardOrMouse:aiKeyboardOrMouse});
}
}
*/

function get scrollPosition(): Number
{
Expand Down Expand Up @@ -266,24 +361,24 @@ class Shared.BSScrollingList extends MovieClip
{
var iFirstItemy: Number = GetClipByIndex(0)._y;
var iItemHeightSum: Number = 0;
var iLastItemShownIndex: Number = 0;
while (iLastItemShownIndex < iScrollPosition) {
EntriesA[iLastItemShownIndex].clipIndex = undefined;
++iLastItemShownIndex;
var i: Number = 0;
while (i < iScrollPosition) {
EntriesA[i].clipIndex = undefined;
++i;
}
iListItemsShown = 0;
iLastItemShownIndex = iScrollPosition;
while (iLastItemShownIndex < EntriesA.length && iListItemsShown < iMaxItemsShown && iItemHeightSum <= fListHeight) {
i = iScrollPosition;
while (i < EntriesA.length && iListItemsShown < iMaxItemsShown && iItemHeightSum <= fListHeight) {
var item: MovieClip = GetClipByIndex(iListItemsShown);
SetEntry(item, EntriesA[iLastItemShownIndex]);
EntriesA[iLastItemShownIndex].clipIndex = iListItemsShown;
item.itemIndex = iLastItemShownIndex;
SetEntry(item, EntriesA[i]);
EntriesA[i].clipIndex = iListItemsShown;
item.itemIndex = i;
item._y = iFirstItemy + iItemHeightSum;
item._visible = true;
iItemHeightSum += item._height;
if (iItemHeightSum <= fListHeight && iListItemsShown < iMaxItemsShown)
++iListItemsShown;
++iLastItemShownIndex;
++i;
}
var iLastItemIndex: Number = iListItemsShown;
while (iLastItemIndex < iMaxItemsShown) {
Expand Down Expand Up @@ -365,9 +460,16 @@ class Shared.BSScrollingList extends MovieClip
scrollPosition = scrollPosition + 1;
}

/**
* MovieClip onPress() aiKeyboardOrMouse == 0
*
* If keyboard (handleInput), aiKeyboardOrMouse is undefined.
*
*/
function onItemPress(aiKeyboardOrMouse: Number): Void
{
if (!bDisableInput && !bDisableSelection && iSelectedIndex != -1) {
//GlobalFunc.getInstance().Deebug("onItemPress() aiKeyboardOrMouse = " + aiKeyboardOrMouse);
dispatchEvent({type: "itemPress", index: iSelectedIndex, entry: EntriesA[iSelectedIndex], keyboardOrMouse: aiKeyboardOrMouse});
return;
}
Expand All @@ -380,10 +482,13 @@ class Shared.BSScrollingList extends MovieClip
dispatchEvent({type: "itemPressAux", index: iSelectedIndex, entry: EntriesA[iSelectedIndex], keyboardOrMouse: aiKeyboardOrMouse});
}

// New: aSelectedEntry is based on highlighted index, which is not always selected index
function SetEntry(aEntryClip: MovieClip, aEntryObject: Object): Void
{
var aSelectedEntry: Object = EntriesA[iHighlightedIndex];

if (aEntryClip != undefined) {
if (aEntryObject == selectedEntry)
if (aEntryObject == aSelectedEntry)
aEntryClip.gotoAndStop("Selected");
else
aEntryClip.gotoAndStop("Normal");
Expand Down
10 changes: 9 additions & 1 deletion src/common/Shared/CenteredScrollingList.as
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ class Shared.CenteredScrollingList extends Shared.BSScrollingList

if (itemIndex != undefined) {
iSelectedIndex = itemIndex;
iHighlightedIndex = itemIndex; //fabd++
bRecenterSelection = true; //fabd++

if (iScrollPosition > 0)
--iScrollPosition;
bMouseDrivenNav = false;
Expand All @@ -224,6 +227,9 @@ class Shared.CenteredScrollingList extends Shared.BSScrollingList
}
if (itemIndex != undefined) {
iSelectedIndex = itemIndex;
iHighlightedIndex = itemIndex; //fabd++
bRecenterSelection = true; //fabd++

if (iScrollPosition < iMaxScrollPosition)
++iScrollPosition;
bMouseDrivenNav = false;
Expand Down Expand Up @@ -273,14 +279,16 @@ class Shared.CenteredScrollingList extends Shared.BSScrollingList

function SetEntry(aEntryClip: MovieClip, aEntryObject: Object): Void
{
var aSelectedEntry: Object = EntriesA[iHighlightedIndex];

if (aEntryClip != undefined) {
if (IsDivider(aEntryObject) == true)
aEntryClip.gotoAndStop("Divider");
else
aEntryClip.gotoAndStop("Normal");

if (iPlatform == 0) {
aEntryClip._alpha = aEntryObject == selectedEntry ? 100 : 60;
aEntryClip._alpha = aEntryObject == aSelectedEntry ? 100 : 60;
} else {
var iAlphaMulti: Number = 4;
if (aEntryClip.clipIndex < iNumTopHalfEntries)
Expand Down
73 changes: 72 additions & 1 deletion src/common/Shared/GlobalFunc.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,81 @@ class Shared.GlobalFunc
static var RegisteredTextFields: Object = new Object();
static var RegisteredMovieClips: Object = new Object();

function GlobalFunc()
// mini console log for debugging
private var debugWindow:MovieClip = null;
private var debugBg:MovieClip = null;
private var debugTxt:TextField = null;

private var DEBUGLOG_HEIGHT:Number = 100;

// singleton instance
private static var inst:GlobalFunc = null;

public function GlobalFunc()
{
if (debugWindow != null) {
throw new Error("Woopsie doo.");
}
CreateDebugLog();
}

/**
* Dynamically create a mini console for debugging.
*
*/
public static function getInstance(): GlobalFunc
{
if (inst == null) {
inst = new GlobalFunc();
}
return inst;
}

private function CreateDebugLog(): Void
{
debugWindow = _root.createEmptyMovieClip("debugWindow", _root.getNextHighestDepth());
debugBg = debugWindow.createEmptyMovieClip("debugBg", debugWindow.getNextHighestDepth());

debugBg.beginFill(0x000000);
debugBg.moveTo(0, 0);
debugBg.lineTo(Stage.width, 0);
debugBg.lineTo(Stage.width, DEBUGLOG_HEIGHT);
debugBg.lineTo(0, DEBUGLOG_HEIGHT);
debugBg.lineTo(0, 0);
debugBg.endFill();
debugBg._alpha = 50;

debugTxt = debugWindow.createTextField("debugTxt", debugWindow.getNextHighestDepth(), 10, 10, (Stage.width/2) - 20, DEBUGLOG_HEIGHT-20);
debugTxt.embedFonts = true;
debugTxt.multiline = true;
debugTxt.wordWrap = false;

debugWindow._x = 0;
debugWindow._y = 0;

var format:TextFormat = new TextFormat("$ConsoleFont", 14, 0xCCCCCC);
debugTxt.setNewTextFormat(format);
}

// Log debug text
public function Deebug(aText: String, ret:Boolean): Void
{
if (debugTxt.text == "") {
ret = false;
}

// newline by default
if (ret !== false) {
ret = true;
}

debugTxt.text += (ret ? "\r" : "") + aText;

if (debugTxt.textHeight > debugTxt._height) {
debugTxt.scroll = debugTxt.textHeight - debugTxt._height;
}
}

static function Lerp(aTargetMin: Number, aTargetMax: Number, aSourceMin: Number, aSourceMax: Number, aSource: Number, abClamp: Boolean): Number
{
var normVal: Number = aTargetMin + (aSource - aSourceMin) / (aSourceMax - aSourceMin) * (aTargetMax - aTargetMin);
Expand Down
Binary file added src/dialoguemenu - fab cs4.fla
Binary file not shown.
Loading