Exemple #1
0
static
int uuTHinshiExitCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  forichiranContext fc;
  tourokuContext tc;
  int cur;

  d->nbytes = 0;

  popCallback(d); /* °ìÍ÷¤ò pop */

  fc = (forichiranContext)d->modec;
  cur = fc->curIkouho;

  popForIchiranMode(d);
  popCallback(d);

  if (tblflag == TABLE1 && cur == SONOTA) {
    tblflag = TABLE2;
    return dicTourokuHinshi(d);
  }

  if (tblflag == TABLE2) {
    cur += SONOTA;
  }

  tc = (tourokuContext)d->modec;

  tc->curHinshi = cur;

  return(dicTourokuHinshiDelivery(d));
}
Exemple #2
0
static
int acDicTourokuYomi(uiContext d, int dn, mode_context dm)
/* ARGSUSED */
{
  popCallback(d);
  return dicTourokuYomi(d);
}
Exemple #3
0
int
getForIchiranContext(uiContext d)
{
  forichiranContext fc;
  int retval = 0;

  if (pushCallback(d, d->modec, NO_CALLBACK, NO_CALLBACK,
                                  NO_CALLBACK, NO_CALLBACK) == 0) {
#ifndef WIN
    jrKanjiError = "malloc (pushCallback) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿";
#else
    jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
#endif
    return(NG);
  }
  
  if((fc = newForIchiranContext()) == NULL) {
    popCallback(d);
    return(NG);
  }
  fc->next = d->modec;
  d->modec = (mode_context)fc;

  fc->prevMode = d->current_mode;
  fc->majorMode = d->majorMode;

  return(retval);
}
Exemple #4
0
int getTourokuContext(uiContext d)
{
  tourokuContext tc;
  int retval = 0;

  if (pushCallback(d, d->modec, NO_CALLBACK, NO_CALLBACK,
                                  NO_CALLBACK, NO_CALLBACK) == 0) {
#ifndef WIN
    jrKanjiError = "malloc (pushCallback) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿";
#else
    jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273"
	"\244\363\244\307\244\267\244\277";
#endif
    return(NG);
  }

  if((tc = newTourokuContext()) == (tourokuContext)NULL) {
    popCallback(d);
    return(NG);
  }
  tc->majorMode = d->majorMode;
  tc->next = d->modec;
  d->modec = (mode_context)tc;

  tc->prevMode = d->current_mode;

  return(retval);
}
Exemple #5
0
static int
vBushuIchiranQuitCatch(uiContext d, int retval, mode_context env)
     /* ARGSUSED */
{
  popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */

  if (((forichiranContext)env)->allkouho != (WCHAR_T **)bushu_char) {
    /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£
       ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */
    freeGetIchiranList(((forichiranContext)env)->allkouho);
  }
  popForIchiranMode(d);
  popCallback(d);

  return(vBushuMode(d, CANNA_MODE_BushuMode));
}
Exemple #6
0
static int
quitHex(uiContext d, int retval, mode_context env)
     /* ARGSUSED */
{
  GlineClear(d);
  popCallback(d);
  currentModeInfo(d);
  return prevMenuIfExist(d);
}
Exemple #7
0
static
int uuTHinshiQuitCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  popCallback(d); /* °ìÍ÷¤ò pop */

  popForIchiranMode(d);
  popCallback(d);

  if (tblflag == TABLE2) {
    tblflag = TABLE1;
    return dicTourokuHinshi(d);
  }

  clearYomi(d);

  return(dicTourokuYomi(d));
}
Exemple #8
0
static int
convBushuQuitCatch(uiContext d, int retval, mode_context env)
{
  popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */

  if (((forichiranContext)env)->allkouho != (WCHAR_T **)bushu_char) {
    /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£
       ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */
    freeGetIchiranList(((forichiranContext)env)->allkouho);
  }
  popForIchiranMode(d);
  popCallback(d);

  makeYomiReturnStruct(d);
  currentModeInfo(d);

  return(retval);
}
Exemple #9
0
static int
bushuQuitCatch(uiContext d, int retval, mode_context env)
     /* ARGSUSED */
{
  popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */

  if (((forichiranContext)env)->allkouho != (WCHAR_T **)bushu_char) {
    /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£
       ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */
    freeGetIchiranList(((forichiranContext)env)->allkouho);
  }
  popForIchiranMode(d);
  popCallback(d);
  currentModeInfo(d);
  GlineClear(d);

  return prevMenuIfExist(d);
}
Exemple #10
0
static
int uuTMakeDicQuitCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */

  freeAndPopTouroku(d);

  return prevMenuIfExist(d);
}
Exemple #11
0
int uuTTangoQuitCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  popCallback(d); /* Æɤߤò pop */

  freeAndPopTouroku(d);
  GlineClear(d);
  currentModeInfo(d);
  return prevMenuIfExist(d);
}
Exemple #12
0
static
int uuTYomiQuitCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  popCallback(d); /* Æɤߤò pop */

  clearTango(d);
  clearYomi(d);

  return(dicTourokuTango(d, uuTTangoQuitCatch));
}
Exemple #13
0
static
int uuT2TangoQuitCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  popCallback(d); /* Æɤߤò pop */

  popYomiMode(d);

  d->status = QUIT_CALLBACK;

  return(0);
}
Exemple #14
0
static int
vBushuExitCatch(uiContext d, int retval, mode_context env)
     /* ARGSUSED */
{
  forichiranContext fc;
  int cur, res;

  popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */

  fc = (forichiranContext)d->modec;
  cur = fc->curIkouho;

  popForIchiranMode(d);
  popCallback(d);

  res = bushuHenkan(d, 1, 1, cur, vBushuIchiranQuitCatch);
  if (res < 0) {
    makeYomiReturnStruct(d);
    return 0;
  }
  return res;
}
Exemple #15
0
static
int uuTMakeDicNoCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */

  freeAndPopTouroku(d);
  defineEnd(d);
  currentModeInfo(d);

  GlineClear(d);
  defineEnd(d);
  return(retval);
}
Exemple #16
0
static int
bushuExitCatch(uiContext d, int retval, mode_context env)
{
  yomiContext yc;

  popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */

  if (((forichiranContext)env)->allkouho != bushu_char) {
    /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£
       ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */
    freeGetIchiranList(((forichiranContext)env)->allkouho);
  }
  popForIchiranMode(d);
  popCallback(d);
  yc = (yomiContext)d->modec;
  if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) {
    restoreFlags(yc);
  }
  retval = YomiExit(d, retval);
  killmenu(d);
  currentModeInfo(d);

  return retval;
}
Exemple #17
0
static int
exitHex(uiContext d, int retval, mode_context env)
{
  killmenu(d);
  if (cvtAsHex(d, d->buffer_return, d->buffer_return, d->nbytes)) {
    GlineClear(d);
    popCallback(d);
    retval = YomiExit(d, 1);
    currentModeInfo(d);
    return retval;
  }
  else {
    return quitHex(d, 0, env);
  }
}
Exemple #18
0
static
int uuTYomiExitCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  tourokuContext tc;

  popCallback(d); /* Æɤߤò pop */

  tc = (tourokuContext)d->modec;

  WStrncpy(tc->yomi_buffer, d->buffer_return, retval);
  tc->yomi_buffer[retval] = (WCHAR_T)'\0';
  tc->yomi_len = retval;

  return(dicTourokuHinshi(d));
}
Exemple #19
0
/************************************************
 *  ñ¸ìÅÐÏ¿¥â¡¼¥É¤òÈ´¤±¤ëºÝ¤ËɬÍפʽèÍý¤ò¹Ô¤¦  *
 ************************************************/
static
int uuT2TangoExitCatch(uiContext d, int retval, mode_context nyc)
/* ARGSUSED */
{
  yomiContext yc;

  popCallback(d); /* Æɤߤò pop */

  yc = (yomiContext)d->modec;
  d->nbytes = retval = yc->kEndp;
  WStrncpy(d->buffer_return, yc->kana_buffer, retval);
  d->buffer_return[retval] = (WCHAR_T)'\0';

  RomajiClearYomi(d);
  popYomiMode(d);
  d->status = EXIT_CALLBACK;

  return retval;
}
Exemple #20
0
int dicTourokuTango(uiContext d, canna_callback_t quitfunc)
{
  tourokuContext tc = (tourokuContext)d->modec;
  yomiContext yc, yc2;
  int retval = 0;

  yc = GetKanjiString(d, (WCHAR_T *)0, 0,
		      CANNA_NOTHING_RESTRICTED,
		      (int)CANNA_YOMI_CHGMODE_INHIBITTED,
		      (int)CANNA_YOMI_END_IF_KAKUTEI,
		      CANNA_YOMI_INHIBIT_NONE,
		      uuTTangoEveryTimeCatch, uuTTangoExitCatch,
		      quitfunc);
  if (yc == (yomiContext)0) {
    freeAndPopTouroku(d);
    defineEnd(d);
    currentModeInfo(d);
    return NoMoreMemory();
  }
  yc2 = GetKanjiString(d, (WCHAR_T *)0, 0,
		      CANNA_NOTHING_RESTRICTED,
		      (int)CANNA_YOMI_CHGMODE_INHIBITTED,
		      (int)!CANNA_YOMI_END_IF_KAKUTEI,
		      CANNA_YOMI_INHIBIT_NONE,
		      uuT2TangoEveryTimeCatch, uuT2TangoExitCatch,
		      uuT2TangoQuitCatch);
  if (yc2 == (yomiContext)0) {
    popYomiMode(d);  /* yc1 ¤ò pop ¤¹¤ë */
    popCallback(d);
    freeAndPopTouroku(d);
    defineEnd(d);
    currentModeInfo(d);
    return NoMoreMemory();
  }
  yc2->generalFlags |= CANNA_YOMI_DELETE_DONT_QUIT;

  yc2->majorMode = CANNA_MODE_ExtendMode;
  yc2->minorMode = CANNA_MODE_TourokuMode;
  currentModeInfo(d);

  return(retval);
}
Exemple #21
0
int dicTourokuHinshi(uiContext d)
{
  tourokuContext tc = (tourokuContext)d->modec;
  forichiranContext fc;
  ichiranContext ic;
  unsigned inhibit = 0;
  int currentkouho, retval = 0, numkouho;

  d->status = 0;

  if(tc->yomi_len < 1) {
    return canna_alert(d, "\306\311\244\337\244\362\306\376\316\317\244\267"
	"\244\306\244\257\244\300\244\265\244\244", acDicTourokuYomi);
                          /* ÆɤߤòÆþÎϤ·¤Æ¤¯¤À¤µ¤¤ */
  }

  if((retval = getForIchiranContext(d)) < 0) {
    freeDic(tc);
    defineEnd(d);
    return(GLineNGReturnTK(d));
  }

  fc = (forichiranContext)d->modec;

  /* selectOne ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */
  if (tblflag == TABLE2) {
    fc->allkouho = hinshitbl2;
    numkouho = HINSHI2_SZ;
  }
  else {
    fc->allkouho = hinshitbl1;
    numkouho = HINSHI1_SZ;
  }

  fc->curIkouho = 0;
  currentkouho = 0;
  if (!cannaconf.HexkeySelect)
    inhibit |= ((unsigned char)NUMBERING | (unsigned char)CHARINSERT); 
  else
    inhibit |= (unsigned char)CHARINSERT; 

  if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, numkouho,
		 BANGOMAX, inhibit, currentkouho, WITH_LIST_CALLBACK,
		 NO_CALLBACK, uuTHinshiExitCatch, 
		 uuTHinshiQuitCatch, uiUtilIchiranTooSmall)) < 0) {
    popForIchiranMode(d);
    popCallback(d);
    freeDic(tc);
    defineEnd(d);
    return(GLineNGReturnTK(d));
  }

  ic = (ichiranContext)d->modec;
  ic->majorMode = CANNA_MODE_ExtendMode;
  ic->minorMode = CANNA_MODE_TourokuHinshiMode;
  currentModeInfo(d);

  /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */
  if(ic->tooSmall) {
    d->status = AUX_CALLBACK;
    return(retval);
  }

  if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) {
    makeGlineStatus(d);
  }

  /* d->status = ICHIRAN_EVERYTIME; */

  return(retval);
}
Exemple #22
0
static
int uuTMakeDicYesCatch(uiContext d, int retval, mode_context env)
/* ARGSUSED */
{
  int err = 0, perr = 0;
  tourokuContext tc;
  WCHAR_T **dp;
  extern int defaultContext;

  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */

  tc = (tourokuContext)d->modec;

  if(defaultContext < 0) {
    if((KanjiInit() < 0) || (defaultContext < 0)) {
      jrKanjiError = KanjiInitError();
      freeAndPopTouroku(d);
      defineEnd(d);
      return(GLineNGReturn(d));
    }
  }
  /* ¼­½ñ¤òºî¤ë */
  if (RkwCreateDic(defaultContext, tc->newDic->name, 0x80) < 0) {
    err++; if (errno == EPIPE) perr++;
    MBstowcs(d->genbuf, "\274\255\275\361\244\316\300\270\300\256\244\313"
	"\274\272\307\324\244\267\244\336\244\267\244\277", 256);
                          /* ¼­½ñ¤ÎÀ¸À®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */
  } else if(RkwMountDic(defaultContext, tc->newDic->name, 0) < 0) {
    err++; if (errno == EPIPE) perr++;
    MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246\245\363"
	"\245\310\244\313\274\272\307\324\244\267\244\336\244\267\244\277", 256);
                          /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ 
  } else if(d->contextCache != -1 && 
    RkwMountDic(d->contextCache, tc->newDic->name, 0) < 0) {
    err++; if (errno == EPIPE) perr++;
    MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246\245\363"
	"\245\310\244\313\274\272\307\324\244\267\244\336\244\267\244\277", 256);
                          /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */
  }

  if(err) {
    if (perr) {
      jrKanjiPipeError();
    }
    makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf));
    freeAndPopTouroku(d);
    defineEnd(d);
    currentModeInfo(d);
    return(0);
  }

  tc->newDic->dicflag = DIC_MOUNTED;

  /* ¼­½ñ¤Î¸õÊä¤ÎºÇ¸å¤ËÄɲ乤ë */
  dp = tc->udic;
  if (dp) {
    while (*dp) {
      dp++;
    }
    *dp++ = WString(tc->newDic->name);
    *dp = 0;
  }

  return(dicTourokuTango(d, uuTTangoQuitCatch));
}
Exemple #23
0
int NpcScriptInterface::luaOpenShopWindow(lua_State* L)
{
    //openShopWindow(cid, items, onBuy callback, onSell callback)
    int32_t sellCallback;
    if (lua_isfunction(L, -1) == 0) {
        sellCallback = -1;
        lua_pop(L, 1); // skip it - use default value
    } else {
        sellCallback = popCallback(L);
    }

    int32_t buyCallback;
    if (lua_isfunction(L, -1) == 0) {
        buyCallback = -1;
        lua_pop(L, 1); // skip it - use default value
    } else {
        buyCallback = popCallback(L);
    }

    if (lua_istable(L, -1) == 0) {
        reportError(__FUNCTION__, "item list is not a table.");
        pushBoolean(L, false);
        return 1;
    }

    std::list<ShopInfo> items;
    lua_pushnil(L);
    while (lua_next(L, -2) != 0) {
        const auto tableIndex = lua_gettop(L);
        ShopInfo item;

        item.itemId = getField<uint32_t>(L, tableIndex, "id");
        item.subType = getField<int32_t>(L, tableIndex, "subType");
        if (item.subType == 0) {
            item.subType = getField<int32_t>(L, tableIndex, "subtype");
            lua_pop(L, 1);
        }

        item.buyPrice = getField<uint32_t>(L, tableIndex, "buy");
        item.sellPrice = getField<uint32_t>(L, tableIndex, "sell");
        item.realName = getFieldString(L, tableIndex, "name");

        items.push_back(item);
        lua_pop(L, 6);
    }
    lua_pop(L, 1);

    Player* player = getPlayer(L, -1);
    if (!player) {
        reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
        pushBoolean(L, false);
        return 1;
    }

    //Close any eventual other shop window currently open.
    player->closeShopWindow(false);

    Npc* npc = getScriptEnv()->getNpc();
    if (!npc) {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushBoolean(L, false);
        return 1;
    }

    npc->addShopPlayer(player);
    player->setShopOwner(npc, buyCallback, sellCallback);
    player->openShopWindow(npc, items);

    pushBoolean(L, true);
    return 1;
}
Exemple #24
0
// new: shop
int NpcScriptInterface::luaSendShop(lua_State *L)
{
	//sendShopWindow(cid, items, onBuy callback, onSell callback)
	int32_t buyCallback = -1;
	int32_t sellCallback = -1;
	std::list<ShopInfo> items;
	Player* player = NULL;

	ScriptEnviroment* env = getScriptEnv();
	Npc* npc = env->getNpc();

	if(lua_isfunction(L, -1) == 0)
	{
        lua_pop(L, 1); // skip it - use default value
	}
	else
	{
		sellCallback = popCallback(L);
	}
	
	if(lua_isfunction(L, -1) == 0)
	{
		lua_pop(L, 1); // skip it - use default value
	}
	else
	{
		buyCallback = popCallback(L);
	}

	if(lua_istable(L, -1) == 0)
	{
        reportError(__FUNCTION__, "item list is not a table.");
		lua_pushnumber(L, LUA_ERROR);
		return 1;
	}

	// first key
	lua_pushnil(L);
	while(lua_next(L, -2) != 0)
	{
        ShopInfo item;
        item.itemId = getField(L, "id");
        item.itemCharges = getField(L, "charges");
		item.buyPrice = getField(L, "buy");
		item.salePrice = getField(L, "sell");
#ifdef __DEBUG_820__
		std::cout 	<< "Added Item " << item.itemId
					<< " with charges " << item.itemCharges
					<< " costs " << item.buyPrice
					<< " and sells for " << item.salePrice
					<< std::endl;
#endif
		items.push_back(item);
		
		lua_pop(L, 1);
	}
	lua_pop(L, 1);
	
	player = env->getPlayerByUID(popNumber(L));
	if(player == NULL) {
		reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushnumber(L, LUA_ERROR);
		return 1;
	}
	player->setShopOwner(env->getNpc(), buyCallback, sellCallback);
	player->sendShop(items);
	player->sendCash(g_game.getMoney(player));
	
	return 1;
}