Public Const gamen_teigi_str_gyo As Integer = 5
'//=========================//
'// 前処理 //
'//=========================//
Sub initAppData()
Dim gyo As Integer
Dim pathdir As String
Dim i As Integer
Dim j As Integer
Dim gamenSu As Integer
Dim sagyoShname As String
Dim sagyoSh As Worksheet
Dim shname() As String
gyo = Sheets("作業一覧").Range("A65536").End(xlUp).Row
If (gyo >= 5) Then
Sheets("作業一覧").Range("A5:C" & CStr(gyo)).Clear
End If
'// 値の初期設定
pathdir = ActiveWorkbook.Path
gyo = 5
'// 主処理:作業一覧の書き出し
gamenSu = 0
For i = 1 To Sheets.Count
'■ 画面一覧の場合
If (Sheets(i).Range("B1") = "画面一覧") Then
'// アプリ用ソース書き出し
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥app_c.txt"
Sheets("作業一覧").Cells(gyo, 2) = Sheets(i).Name
Sheets("作業一覧").Cells(gyo, 3) = pathdir & "¥" & Sheets(i).Range("B2") & ".c"
gyo = gyo + 1
'// アプリ用ヘッダー書き出し
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥app_h.txt"
Sheets("作業一覧").Cells(gyo, 2) = Sheets(i).Name
Sheets("作業一覧").Cells(gyo, 3) = pathdir & "¥" & Sheets(i).Range("B2") & ".h"
gyo = gyo + 1
'// バージョン用書き出し
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥version_h.txt"
Sheets("作業一覧").Cells(gyo, 2) = Sheets(i).Name
Sheets("作業一覧").Cells(gyo, 3) = pathdir & "¥version.h"
gyo = gyo + 1
End If
'■ 各画面定義の場合
If (Sheets(i).Range("B1") = "画面定義") Then
'// 新規画面用にシート名保存
ReDim Preserve shname(gamenSu + 1)
shname(gamenSu) = Sheets(i).Name
sagyoShname = "@" & Sheets(i).Name
gamenSu = gamenSu + 1
'// 画面用ソース書き出し
If (Sheets(i).Cells(gamen_teigi_str_gyo, 1) = "") Then
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥gamen_c.txt"
Else
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥gamen_b_c.txt"
End If
Sheets("作業一覧").Cells(gyo, 2) = sagyoShname
Sheets("作業一覧").Cells(gyo, 3) = pathdir & "¥" & Sheets(i).Range("D2") & ".c"
gyo = gyo + 1
'// 画面用ヘッダ書き出し
If (Sheets(i).Cells(gamen_teigi_str_gyo, 1) = "") Then
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥gamen_h.txt"
Else
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥gamen_b_h.txt"
End If
Sheets("作業一覧").Cells(gyo, 2) = sagyoShname
Sheets("作業一覧").Cells(gyo, 3) = pathdir & "¥" & Sheets(i).Range("D2") & ".h"
gyo = gyo + 1
End If
Next
'// 主処理2:作業用画面定義の作成
For i = 0 To gamenSu - 1
Set sagyoSh = Sheets.Add()
sagyoShname = "@" & shname(i)
sagyoSh.Name = sagyoShname
Call makeSagyoSheet(sagyoShname, shname(i))
Set sagyoSh = Nothing
Next
'// 主処理3:画面イベント処理の作成
For i = 0 To gamenSu - 1
sagyoShname = "@" & shname(i)
j = 5
Do While (Sheets(sagyoShname).Cells(j, 13) <> "")
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥gamen_event_h.txt"
Sheets("作業一覧").Cells(gyo, 2) = "@" & Sheets(sagyoShname).Cells(j, 13)
Sheets("作業一覧").Cells(gyo, 3) = pathdir & "¥" & Sheets(sagyoShname).Cells(j, 13) & ".h"
gyo = gyo + 1
Sheets("作業一覧").Cells(gyo, 1) = pathdir & "¥gamen_event_c.txt"
Sheets("作業一覧").Cells(gyo, 2) = "@" & Sheets(sagyoShname).Cells(j, 13)
Sheets("作業一覧").Cells(gyo, 3) = pathdir & "¥" & Sheets(sagyoShname).Cells(j, 13) & ".c"
gyo = gyo + 1
j = j + 1
Loop
Next
End Sub
'//=========================//
'// 後処理 //
'//=========================//
Sub freeAppData()
Dim sagyoShname As String
Dim sagyoSh As Worksheet
Dim shname() As String
Dim i As Integer
Dim j As Integer
'// 主処理1:作業用画面定義の取得
j = 0
For i = 1 To Sheets.Count
If (Left(Sheets(i).Name, 1) = "@") Then
'// 新規画面用にシート名保存
ReDim Preserve shname(j + 1)
shname(j) = Sheets(i).Name
j = j + 1
End If
Next
'// 主処理2:作業用画面定義の削除
Application.DisplayAlerts = False
For i = 0 To j - 1
Sheets(shname(i)).Delete
Next
Application.DisplayAlerts = True
End Sub
'//=========================//
'// 作業用シート書き出し //
'//=========================//
Sub makeSagyoSheet(shname As String, motoname As String)
Dim sakiSheet As Worksheet
Dim motoSheet As Worksheet
Dim lastGyo As Integer
Dim i As Integer
Dim j As Integer
Dim sts As Integer
Dim strMenuGyo As Integer
Dim strEventGyo As Integer
'// 元、先シートと最後の行を求める
Set sakiSheet = Sheets(shname)
Set motoSheet = Sheets(motoname)
lastGyo = motoSheet.Range("A65536").End(xlUp).Row
sts = 0
For i = 1 To lastGyo
Select Case sts
Case 0:
If (motoSheet.Cells(i, 1) = "メニュー一覧") Then
sts = 1
strMenuGyo = i
For j = 1 To 4
sakiSheet.Cells(i - strMenuGyo + 3, j + 14) = motoSheet.Cells(i, j)
Next
ElseIf (motoSheet.Cells(i, 1) = "イベント一覧") Then
sts = 2
strEventGyo = i
Call makeEventList(sakiSheet, motoSheet, strEventGyo, i)
Else
For j = 1 To 12
sakiSheet.Cells(i, j) = motoSheet.Cells(i, j)
Next
End If
Case 1:
If (motoSheet.Cells(i, 1) = "イベント一覧") Then
sts = 2
strEventGyo = i
Call makeEventList(sakiSheet, motoSheet, strEventGyo, i)
Else
For j = 1 To 4
sakiSheet.Cells(i - strMenuGyo + 3, j + 14) = motoSheet.Cells(i, j)
Next
End If
Case 2:
Call makeEventList(sakiSheet, motoSheet, strEventGyo, i)
End Select
Next
'//あとしまつ
Set sakiSheet = Nothing
Set motoSheet = Nothing
End Sub
'//=========================//
'// イベント一覧書き出し //
'//=========================//
Sub makeEventList(sakiSheet As Worksheet, motoSheet As Worksheet, _
strEventGyo As Integer, gyo As Integer)
Dim j As Integer
Dim i As Integer
Dim ecName As String
Dim eventName As String
Dim eGyo As Integer
Dim eventSheet As Worksheet
Dim eWriteGyo As Integer
i = gyo
For j = 1 To 6
If (motoSheet.Cells(i, 2) <> "") And _
(j >= 3) And (j <= 4) And _
(motoSheet.Cells(i, j) = "") Then
sakiSheet.Cells(i - strEventGyo + 3, j + 19) = 0
Else
sakiSheet.Cells(i - strEventGyo + 3, j + 19) = motoSheet.Cells(i, j)
End If
Next
'// イベントモードの設定
sakiSheet.Cells(i - strEventGyo + 3, 26) = _
getEventMode(motoSheet.Cells(i, 2), motoSheet.Cells(i, 3), motoSheet.Cells(i, 4))
'// イベントがわかんない行(イベント種類がない)は、ここで終わり
If (sakiSheet.Cells(i - strEventGyo + 3, 26) = "") Then
Exit Sub
End If
'// イベントクラスとメソッド取得
ecName = motoSheet.Cells(i, 5)
eventName = motoSheet.Cells(i, 6)
eGyo = 5
Do While (sakiSheet.Cells(eGyo, 13) <> "")
If (sakiSheet.Cells(eGyo, 13) = ecName) Then
Exit Do
End If
eGyo = eGyo + 1
Loop
'// イベントシートの取得(なければ追加)
If (sakiSheet.Cells(eGyo, 13) = "") Then
sakiSheet.Cells(eGyo, 13) = ecName
Set eventSheet = makeEventSheet(ecName, motoSheet.Range("D2"))
Else
Set eventSheet = Sheets(CStr("@" & ecName))
End If
'// イベントの書き出し
eWriteGyo = eventSheet.Range("A65536").End(xlUp).Row + 1
eventSheet.Cells(eWriteGyo, 1) = eWriteGyo - 4
eventSheet.Cells(eWriteGyo, 2) = eventName
Set eventSheet = Nothing
End Sub
'//=========================//
'// イベントモード決定 //
'//=========================//
Function getEventMode(eCode As String, wParam As String, dwParam As String) As String
If (InStr(eCode, "EVT") = 0) Then
getEventMode = ""
Exit Function
End If
If (dwParam = "") Then
If (wParam = "") Then
getEventMode = "IEVENTLIST_KIND_ECODE"
Else
getEventMode = "IEVENTLIST_KIND_WPARAM"
End If
Else
getEventMode = "IEVENTLIST_KIND_DWPARAM"
End If
End Function
'//=========================//
'// イベントシート作成 //
'//=========================//
Function makeEventSheet(ecName As String, gamenName As String) As Worksheet
Dim sagyoSh As Worksheet
Set sagyoSh = Sheets.Add()
sagyoSh.Name = "@" & ecName
sagyoSh.Range("A1") = "イベントクラス名"
sagyoSh.Range("B1") = ecName
sagyoSh.Range("C1") = StrConv(ecName, vbUpperCase)
sagyoSh.Range("A2") = "画面名"
sagyoSh.Range("B2") = gamenName
sagyoSh.Range("A4") = "イベント一覧"
Set makeEventSheet = sagyoSh
End Function
|